How would
:first
be different from:first-child
? Every HTML element is a child of some other element in the DOM except<html>
which is the root element. – BoltClockIt’d be since you don’t know the parent element. – fomicz
You don’t need to know the parent element for :first-child
or :nth-child()
to work. They will just work, even if you don’t specify the parent element.
The following selector is guaranteed to match any appropriate .select-me
element regardless of what its parent element is:
.select-me:nth-child(2)