Kyle Schmelzer
Kyle Schmelzer

Reputation: 153

How to add a mailto to a sentence without extra spacing?

I have a simple sentence.

-For further information, email [email protected].

I need that sentence to be regular text, non clickable, until i get to "[email protected]" then i need that to be clickable and open up your email.

I tried coding it like so:

<p id="email">For further information, email <a href="[email protected]">[email protected]</a>.</p>

The problem im having is when i open up the site, there's a huge gap between "email" and "[email protected]" and it simply doesn't look good. How can i code this without a gap?

Is this something i would do in CSS?

Thanks again!

Upvotes: 0

Views: 464

Answers (3)

priyanka priya
priyanka priya

Reputation: 1

function validateEmail() {
    var text = document.forms["anything"]["email"].value;

    var atpos=text.indexOf("@");
    var dotpos=text.lastIndexOf(".");
if (atpos < 1 || dotpos < atpos+2 || dotpos+2 > text.lenght) {  
alert ("please enter valid email address.");
return false;
    }

}

Upvotes: 0

Tariq
Tariq

Reputation: 2569

Apply in-line styling in you anchor tag to remove any margin/padding in your anchor tag:

<a style="margin-left: 0px; padding-left: 0px;" href="[email protected]">[email protected]</a>

It will help avoid disturbing styling from elsewhere in your page/application.

Upvotes: 1

I don't understand why thats happening to you, as whenever I try it, it works exactly as you describe it. However, I believe that your problem is your browser.

Though one minor thing: there is one misplaced period after the < a > (I added a comment where it was)

<p id="email">For further information, email <a href="[email protected]">
[email protected]</a>.<!--Right here to the left--></p>

You can see your code work flawsessly@

http://jsfiddle.net/e66peagc/

Upvotes: 1

Related Questions