Css first-of-type selector

Could someone please explain why its not selecting the first .row element, even though its wrapped in a container?

https://codepen.io/Povilaitis/pen/oNZyzGj?editors=1100

Hello @Povilaitis
:first-of-type are for https://developer.mozilla.org/en-US/docs/Web/CSS/:first-of-type

.row is not type .row is certain class

hope that help and have a nice day :slight_smile:

So its not possible to use :first-of-type selector to select the first element with a given class. The :first-of-type pseudo-class selects the first element of its type ( div , p , etc). Using a class selector (or a type selector) with that pseudo-class means to select an element if it has the given class (or is of the given type) and is the first of its type among its siblings.

for further reading:

1 Like