We would like to know how to nth-child(even) Style div odd and even.
<!--from ww w. ja v a 2s. c o m-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {
width: 50px;
height: 50px;
}
div:nth-child(odd) {
background-color: red;
}
div:nth-child(even) {
background-color: blue;
}
</style>
</head>
<body>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</body>
</html>
The code above is rendered as follows: