14

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/

Johan Hjalmarsson
  • 3,433
  • 4
  • 39
  • 64
joe11093
  • 418
  • 2
  • 4
  • 16

5 Answers5

12

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;
}
dk_french032
  • 638
  • 1
  • 7
  • 22
2

I think you should define the default state as well, so for example:

a:link { text-decoration: underline; }
a:visited { text-decoration: none; }
Alex Szabo
  • 3,274
  • 2
  • 18
  • 30
  • I tried this too, but it also didn't work. – joe11093 Jul 24 '14 at 13:45
  • @joe11093 Just a question, did you try to add it in a style tag, like this? -- this should be posted in the head section of the html page. – Alex Szabo Jul 24 '14 at 13:46
  • yes. all the css i wrote for this one is written in the head of the html page. – joe11093 Jul 24 '14 at 13:50
0

If existing code is not working for you then please add "!important" in your property.

a:visited
{ 
     text-decoration: none !important;
}
Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50
0

Or try

outline: 0;

It might work on FF.

ChoiBedal
  • 111
  • 7
0

As mentioned before, changing text-decoration for :visited anchors does not work. But you could do the following:

a {
    border-bottom:1px solid #000;
    text-decoration:none;
}

a:visited { 
    border-bottom-color:rgba(255,255,255,0);
}

This works fine for me: http://jsfiddle.net/Whre/N8c3A/ To test it using chrome inspect the anchor with the developer tools, rightclick the markup and say "Force element state" -> ":visited".

SVSchmidt
  • 6,269
  • 2
  • 26
  • 37