Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a:visited bold in XHTML/CSS?

Tags:

html

css

xhtml

I have tried the following with no luck:

a:visited
{
   font-weight: bold;
}

EDIT: Removed the space after the ":", but it still doesn't work.

like image 840
sveinungf Avatar asked Dec 12 '22 07:12

sveinungf


2 Answers

Ah — I believe this won’t work in recent browsers, because they disabled most styles for visited links to prevent websites from detecting the user’s web browsing history:

  • http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/

For example, in Chrome 15, the visited link on this fiddle has a different colour, but is not bold:

  • http://jsfiddle.net/XbVpe/

Looks like Firefox added this in version 4:

  • https://developer.mozilla.org/en/CSS/Privacy_and_the_:visited_selector
like image 92
Paul D. Waite Avatar answered Dec 18 '22 06:12

Paul D. Waite


Get rid of the space:

a:visited {
    font-weight: bold;
}

The reason it didn't work before is because space is a descendent selector: http://www.w3.org/TR/CSS2/selector.html#descendant-selectors

A descendant selector is made up of two or more selectors separated by white space. A descendant selector of the form "A B" matches when an element B is an arbitrary descendant of some ancestor element A.

like image 29
David Hu Avatar answered Dec 18 '22 07:12

David Hu