Let's say I have the following structure for a list:
<ul>
<li></li><li></li>
<li></li><li></li>
</ul>
and each <li>is 50% of the width, so I want each of the two to have the same background color as follows:
<ul>
<li style="background:#CCC;"></li><li style="background:#CCC;"></li>
<li style="background:#DDD;"></li><li style="background:#DDD;"></li>
<li style="background:#CCC;"></li><li style="background:#CCC;"></li>
<li style="background:#DDD;"></li><li style="background:#DDD;"></li>
</ul>
Can I do this with the nth-child () CSS selector to minimize code ?
source
share