even and odd Selector

by Andrea Biagi

HTML

<body>

<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>

<p><b>Note:</b> Internet Explorer 8 and earlier versions do not support the :nth-child() selector.</p>

</body>

CSS

p:nth-child(even) {
    background: red;
}

p:nth-child(odd) {
    background: blue;
}