WebsiteGear Logo Log In
New User? Sign Up
About | Contact | FAQ
Home Discussion Forums Website Development HTML & DHTML
New Post New Post | Report Abuse Report Abuse


Highlight table row on mouseover
Post by indi on Sep 9, 2008 12:08:08 PM CST


From usability point of view, it is good to highlight the row in a table when the user moves the cursor over that table row. It becomes very easy to see the row clearly in reports etc.

Here is the easiest way to achieve this using stylesheet (CSS)

tr:hover { background-color: COLOR_CODE;}

Now, if there are stylesheets assigned to show different colors for odd and even rows, then add a new hover directive as below.

tr.oddrow:hover { background-color: COLOR_CODE;}
tr.evenrow:hover { background-color: COLOR_CODE;}

The above stylesheet change will work in Firefox, but not in IE, unless the page is defined as strict DOCTYPE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Here is what Microsoft says about using :hover
----------------
Windows Internet Explorer 7 and later, in standards-compliant mode (strict !DOCTYPE), can apply the :hover pseudo-class to any element, not only links. If the pseudo-class is not applied specifically to an element in the selector, such as the A tag, the Universal (*) Selector is assumed. Indiscriminate use of the :hover pseudo-class can negatively impact page performance.
------------------

The other way to achieve this is using JavaScripting.

<tr onMouseOver="this.bgColor='yellow';" onMouseOut="this.bgColor='white';">



Submit To Slashdot Slashdot | Submit To Digg.com Digg | Save in del.icio.us Del.icio.us | Submit To Reddit Reddit
REPLIES & COMMENTS Post a Reply
LATEST FORUM POSTINGS
Nav New Keywords Utils Site | Mar 16, 2009
Nav Choose Best Web Hosting Company | Mar 12, 2009
Nav Online tutorials for programming languages | Mar 6, 2009
Nav How to find out what code is used in website? | Feb 26, 2009
Nav How to make flash 3D sphere photo gallery | Feb 24, 2009
Nav What are H1, H2 & so on in web design? | Feb 11, 2009
Nav Best tool for real estate web design | Feb 11, 2009
Nav finding a job | Feb 11, 2009
FORUM SEARCH

FEATURED NEWS | POPULAR NEWS
Submit News | View More News View More News


Copyright © 2003-2009 WebsiteGear Inc. All rights reserved.
About | Advertise | Submit Content | Privacy | Agreement | Contact