Link to home
Start Free TrialLog in
Avatar of Allen Pitts
Allen PittsFlag for United States of America

asked on

CSS Alternating row color

Hello Experts.
Would like to make every other color in a table light grey
to make it easier to read. Found several websites  that
show snippets like
tr:nth-child(odd)            { background-color:#eee; }
tr:nth-child(even)            { background-color:#fff; }
but when I put them into a page they don't work.

So I found a site that shows the complete page at
and there is an example from this page at
that looks like what is desired.
Like this
User generated imageWhen a VIew>Source is done the code copied below
is displayed.
When the code is pasted into an HTML file I get
User generated image
Using IE 10 for both views.
How can the same code, one view from the
web and one viewed from the hard drive
display so differently?


Allen in Dallas


tr:nth-child(even) {
background-color: #0000ff;
color: #ffffff;



Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Just checked that code from file / web in FF and IE (8,9,10,11) Works everywhere except IE8 - which is expected because IE8 does not have support for nth-child.

Have you checked the page from other browsers?
Avatar of Prasadh Baapaat
Prasadh Baapaat
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Allen Pitts