Welcome to WebmasterWorld Guest from 54.145.207.36

Forum Moderators: not2easy

Using "Bare Pseudo Classes"?

Beware you should test in NN7..

   
10:14 am on Mar 8, 2003 (gmt 0)

WebmasterWorld Senior Member suzyuk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi a few weeks ago someone here replied to a post (sorry I can't remeber which one) and said that I could shorten my code because I didn't have to have the anchor link before it's state..i.e.

instead of:
a:link, a:visited, a:hover, a:active
Use
:link :visited :hover :active

However I would just like to make a reference to "arbitrary-hover" [devedge.netscape.com] and from it this quote especially:

In browsers based on Netscape Gecko builds later than 20020410 (Netscape 6.1+), :hover styles can be applied to any element in a document. Thus authors who have used bare pseudo-classes, or bare class-pseudo-class combinations, are at risk for seeing hover styles applied to more than just their links. The most reliable fix is to add the anchor element to the selectors, like this:

a:hover {color: red;}
a.nav:hover {color: red;}

Basically using the "bare pseudo class" could cause every element on the page to change it's state on hover, admittedly the article goes on to futher explain that it may not happen in quirks mode, but the possibility is always there.

My advice always add the element to the selector ;) Anyhow for me that makes the code easier to read later

Suzy

10:22 am on Mar 8, 2003 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thanks for your advice, Suzy. And I agree wholeheartedly. Besides, that leaves some room for future CSS standards (and browsers) as well. No need to go back and change your "old" CSS if you use the full a:pseudo selector :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month