In HTML

<p>0</p>
<div>1</div>
<div>2</div>
<p>3</p>
<div>4</div>
<div>5</div>
<div>6</div>

The Selector div:nth-child(3) will choose the 3rd element from all elements in the level where div is, then check if the 3rd element is a ‘div’. In this case, the 3rd element is a ‘div’, so it works(<div>2</div>), but Selector div:nth-child(4) will select the 4st element which is ‘p’ (<p>3</p>), it’s not a ‘div’, so it doesn’t work.

However, the Selector div:nth-of-type(3) will choose the 3rd ‘div’ from all ‘div’s in the level where div is, so it choose the <div>4</div>.