XML technologies / CSS / CSS Cookbook / Tables / Highlighting active table rows
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
A table row should be highlighted when the mouse pointer is over it (see the next figure).
Solution
Use the pseudo-class :hover together with the element selector tr:
tr:hover {
background: yellow;
}Figure: The table row currently under the mouse pointer is highlighted.
Discussion
You may already know the pseudo-class :hover from creating rollover effects for links. However, the CSS specification does not restrict :hover to that use. It can be applied to any element, such as p or div.
This technique does not work everywhere, because Internet Explorer 6 for Windows and earlier versions do not support :hover.
See also
The CSS 2.1 specification on dynamic pseudo-classes.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln