Div odd and even css

<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>

 

.box:nth-of-type(odd) {
background-color:#000;
}
    
.box:nth-of-type(even) {
background-color:#fff;
}

.box {
display: inline-block;
width: 100px;
height: 100px;
border: 1px solid #f00;
}