How to remove underline from a link in HTML?

Html

Html Problem Overview


In my page I have put some links under which I don't want any line, so, how can I remove that using HTML?

Html Solutions


Solution 1 - Html

Inline version:

<a href="http://yoursite.com/" style="text-decoration:none">yoursite</a>

However remember that you should generally separate the content of your website (which is HTML), from the presentation (which is CSS). Therefore you should generally avoid inline styles.

See John's answer to see equivalent answer using CSS.

Solution 2 - Html

This will remove all underlines from all links:

a {text-decoration: none; }

If you have specific links that you want to apply this to, give them a class name, like nounderline and do this:

a.nounderline {text-decoration: none; }

That will apply only to those links and leave all others unaffected.

This code belongs in the <head> of your document or in a stylesheet:

<head>
    <style type="text/css">
        a.nounderline {text-decoration: none; }
    </style>
</head>

And in the body:

<a href="#" class="nounderline">Link</a>

Solution 3 - Html

I suggest to use :hover to avoid underline if mouse pointer is over an anchor

a:hover {
   text-decoration:none;
}

Solution 4 - Html

  1. Add this to your external style sheet (preferred):

     a {text-decoration:none;}
    
  2. Or add this to the <head> of your HTML document:

     <style type="text/css">
      a {text-decoration:none;}
     </style>
    
  3. Or add it to the a element itself (not recommended):

     <!-- Add [ style="text-decoration:none;"] -->
     <a href="http://example.com" style="text-decoration:none;">Text</a>
    

Solution 5 - Html

The other answers all mention text-decoration. Sometimes you use a Wordpress theme or someone else's CSS where links are underlined by other methods, so that text-decoration: none won't turn off the underlining.

Border and box-shadow are two other methods I'm aware of for underlining links. To turn these off:

border: none;

and

box-shadow: none;

Solution 6 - Html

The following is not a best practice, but can sometimes prove useful

It is better to use the solution provided by John Conde, but sometimes, using external CSS is impossible. So you can add the following to your HTML tag:

<a style="text-decoration:none;">My Link</a>

Solution 7 - Html

All the above-mentioned code did not work for me. When I dig into the problem I realize that it was not working because I'd placed the style after the href. When I placed the style before the href it was working as expected.

<a style="text-decoration:none" href="http://yoursite.com/">yoursite</a>

Solution 8 - Html

<style="text-decoration: none">

The above code will be enough.Just paste this into the link you want to remove underline from.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPaic TenView Question on Stackoverflow
Solution 1 - Htmlpatryk.bezaView Answer on Stackoverflow
Solution 2 - HtmlJohn CondeView Answer on Stackoverflow
Solution 3 - HtmlRomanView Answer on Stackoverflow
Solution 4 - Html0b10011View Answer on Stackoverflow
Solution 5 - HtmlJoe GoltonView Answer on Stackoverflow
Solution 6 - HtmlnebulousGirlView Answer on Stackoverflow
Solution 7 - HtmlGanesh M SView Answer on Stackoverflow
Solution 8 - Htmlsd1990View Answer on Stackoverflow