Help in CSS?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
adilmarwat2004
Forum Commoner
Posts: 44
Joined: Fri Sep 04, 2009 11:28 pm

Help in CSS?

Post by adilmarwat2004 »

I have table in dynamic table php. In which different data fields contains.

I want to set the 1st row color "red" and 2nd row "white" and again 3rd row "red" and so on.

How can I set it that it could be readable every row easily.

--
Adil Rauf
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Help in CSS?

Post by pickle »

Generally how this is done is you give every second row a class of "odd" - usually by using the modulus operator in some way. Then in CSS, you give all table rows one colour, and rows of class "odd" another colour.

FYI, the term for this is "zebra striping", and I'm sure Google has some helpful resources if necessary.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Help in CSS?

Post by daedalus__ »

css3 has new selectors which make this super easy. something to keep in mind for the future
Post Reply