Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Accredited PayPal World Seller
Style every second/alternate div :nth-child() or :nth-of-type() selectors greencode msg:4256654 4:36 pm on Jan 22, 2011 (gmt 0) Not sure why I've never had to do this before but is there any way to style every other div? I have a series of rows that are dynamically created and would like to add a different background colour to every other div row. i.e grey white grey white etc.
alt131 msg:4257225 11:22 am on Jan 24, 2011 (gmt 0)
Hi Greencode, the css3 selectors :nth-child(), or :nth-of-type() would achieve what you want, but support is poor except for the most modern browsers. If the divs already have attributes the attribute selectors [ w3.org] are another option, with much wider support, including ie7+.