5

I have this snippet:

<p><a href="http://www.example.com">Link to example site.</a> </p>

a:link{
  color:green;
  text-decoration:none;
}


a:visited{
  color:pink;
  text-decoration:underline;
}

a:hover{
  color:yellow;
  text-decoration:underline;
}

Can someone explain why the text-decoration:underline; for a:visited does not work?

4

The functionality of :visited pseudoclass has been restricted in many modern browsers (Fx4, IE9, Chrome) to prevent CSS exploit. You can read about it here, but the crux is:

For many years the CSS :visited selector has been a vector for querying a user’s history. It’s not particularly dangerous by itself, but when it’s combined with getComputedStyle() in JavaScript it means that someone can walk through your history and figure out where you’ve been.

  • And crucially, whilst some CSS properties (like color) can be changed, the browser "lies" when reading back the value and returns the default (unvisited) value for that property. – MrWhite Dec 17 '15 at 12:09
0

The text-decoration has to be the same on every type of link.
Look at this question from stackoverflow.com

When you remove your text-decoration:none from a:link, a:visited would be underlined.

  • No, i want my link to be underlined only after the link has been clicked. when i remove text-decoration:none from a:link by default the link is underlined – Akash Preet Dec 17 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.