CSS Alternating row color

Allen Pitts
Allen Pitts used Ask the Experts™
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
CSS-alternating-rowa.gifWhen a VIew>Source is done the code copied below
is displayed.
When the code is pasted into an HTML file I get
Code from View Source
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;



Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

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?
Web Designer & Developer
Hi 9apit,
I answered to another question by you where CSS borders were not working in your browser....

I had suggested to add the meta tag...  maybe its the same problem again... add below tag to page and check.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Open in new window

Allen PittsBusiness analyst



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial