Search code examples
htmlcsshyperlinkvisited

Removing the underline from under a visited link


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/


Solution

  • 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;
    }