Skip to main content
added a code snippet
Source Link
Soufian
  • 189
  • 2
  • 3

Itthis works well for me  :

.home .red:nth-child(1) { border: 1px solid red; } 

.home .red:nth-of-type(1) { border: 1px solid red; }
<div class="home"> <span>blah</span> <p class="red">first</p> <p class="red">second</p> <p class="red">third</p> <p class="red">fourth</p> </div>

It works well for me  :

.home .red:nth-child(1) { border: 1px solid red; } 

this works for me:

.home .red:nth-of-type(1) { border: 1px solid red; }
<div class="home"> <span>blah</span> <p class="red">first</p> <p class="red">second</p> <p class="red">third</p> <p class="red">fourth</p> </div>

Source Link
Soufian
  • 189
  • 2
  • 3

It works well for me :

.home .red:nth-child(1) { border: 1px solid red; }