Removing the underline from under a visited link

joe11093 picture joe11093 · Jul 24, 2014 · Viewed 12.1k times · Source

What is the CSS code that I need to write in order to remove the underline from these link after visiting them?

<ul id = "header">
    <li><a href="sigur ros.html"> Home </a> </li>
    <li>Images</li>
    <li>Videos</li>
</ul>

I tried this:

a:visited { text-decoration: none; }

but it didn't work.

Here is a fiddle showing the problem: http://jsfiddle.net/litari/X2Yjk/1/

Answer

dk_french032 picture dk_french032 · Jul 24, 2014

You can't change text-decoration in :visited

Rather set text-decoration:none on anchors and text-decoration:underline on links you want underlined. For example you can use a class to achieve this.

a
{
   text-decoration:none;
}

a.underlined
{
   text-decoration:underline;
}