Why is link underline appearing after clicking the link?

That is because the default CSS values for links are declared by different browsers. A link has 4 official states.

  • Normal
  • Hover
  • Active (On mouseclick)
  • Visited
  • (Focus)

In CSS you can declare the style for each of these. If you want the link not to display the text-decoration in these states:

a, a:hover, a:active, a:visited, a:focus {
    text-decoration:none;
}

Answer to your comment

Yes, you can replace the a with a classname. For instance, you have a link with the class ‘myLink’.

You can make the CSS:

.myLink, .myLink:hover, .myLink:active, .myLink:visited, .myLink:focus {
    text-decoration:none;
}

Leave a Comment