If you hover over or next to the above heading "A:hover and named anchors" in Mozilla, Netscape 6+, or Opera 7 you will notice that it is subject to the same hover effects as the link below. (The A element is made block-level in this example to make the effect more apparent in Netscape.)
This is a link to the heading "A:hover and named anchors"
If you use "named anchors" and would like to prevent unwanted effects in browsers that support the :hover pseudo-class on objects other than just links, you have a few options but only one true solution.
This test was performed on Windows operating system with Mozilla 1, Netscape 6.2, Internet Explorer 5.5 & 6, Opera 5.12, 6.03, & 7.01 and Netscape Navigator 4.61/4.79; results do not necessarily include previous browser versions or other operating systems.
Creating a combined pseudo-class selector for the hover effect solves the issue and works in IE5&6, M1, N6+, and O7. However, Opera 5&6 do not support combining pseudo-classes. In fact, Opera 5&6 treat the selectors as simply "a:link, a:visited" which can create additional problems.
See this solution in action -->
Instead of using a named anchor, simply ID the targeted element. When used inline, you could wrap a SPAN around the target and ID the SPAN tag. The downside for this option is that older browsers, such as Netscape 4, do not support the id attribute. Therefore the targeted links will not work in older browsers.
This is a link to the above heading "Possible Solution: ID targeted element"
This is a link to the targeted inline element SPAN in the paragraph above.
You could make hover declarations using the attribute selector a[href]:hover. This works in M, N6+, and O5+, but IE5&6 do not support attribute selectors. Therefore IE5&6 users would not see a hover effect.
See this solution in action -->
Counter-declare any declarations made for the hover with the attribute selector a[name]:hover. This solution is recommended for compatibility with all browsers. The hover effect is rendered on links in all browsers that support the :hover pseudo-class, but is not rendered on named anchors in newer browsers.
See this solution in action -->
"Notes on suggesting link styles"
http://www.people.fas.harvard.edu/~dbaron/css/1999/09/links
"A revised method of defining link pseudo-classes"
http://www.evolt.org/article/view/17/35541/index.html
Tim Rivera would like to thank the following people for their suggestions: Kristof Neirynck, Rijk van Geijtenbeek, Ric
Test date: June 20, 2002