How can I select odd and even elements with CSS?
<p>Say I have some divs:</p>
<pre><code>&lt;div class=&quot;box-1&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;box-2&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;box-3&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;box-4&quot;&gt;&lt;/div&gt;
</code></pre>
<p>If these boxes need to be alternate colours I need to create some CSS which basically does the following:</p>
<pre><code>.box-(odd-number) {
    color:#000;
}
.box-(even-number) {
    color:#fff;
}
</code></pre>
<p>Obviously I know the above is not the correct syntax. Could some one point me in the right direction?</p>
<p>Thanks</p>