Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style>
/* Selects every fourth element among any group of siblings */
:nth-child(4) {
  background-color: yellow;
}
/* Selects the second element of div siblings */
div:nth-child(2) {
  background-color: red;
}
/* Selects the second li element in a list */
li:nth-child(2) {
  background-color: lightgreen;
}
</style>
</head>
<body>
<h1>Demo of :nth-child</h1>
<div>
  <p>This is some text.</p>
</div>
<div>
  <p>This is some text.</p>
</div>
<div>
  <p>This is some text.</p>
</div>
<ul>
  <li>First list item</li>
  <li>Second list item</li>
  <li>Third list item</li>
  <li>Fourth list item</li>
  <li>Fifth list item</li>
</ul>
</body>
</html>