While IE 6 only offers support for the :hover
pseudo class on links, IE 7 extends this functionality to most elements.
David mentioned that in quirks mode, this may not function as expected. This is because IE tends to revert back to a version more similar to IE 4 in quirks mode, allowing for many IE-specific features while removing certain standards-compliant ones.
If you need the :hover
effect on a block element with compatibility all the way back to IE 6, you can achieve this by using a link element styled as a block using CSS. Keep in mind that a link can only contain inline elements (not div
s), so if you want block elements within the link, they will need to be styled accordingly:
CSS:
.hoverlink { display: block; }
.hoverlink:hover { background: #eee; }
.hoverlink .item { display: block; }
HTML:
<a href="..." class="hoverlink">
<span class="item">Line 1</span>
<span class="item">Line 2</span>
<span class="item">Line 3</span>
</a>
(It's also worth considering the impact of this technique on search engines. A link tends to have better SEO value when it contains descriptive text about what it is linking to.)