:nth-child and :nth-of-type
Select elements by their position in a parent using nth formulas and type selectors.
What are Structural Pseudo-classes?
Structural pseudo-classes select elements based on their position within their parent. They eliminate the need for adding classes or JavaScript to target specific child elements.
:first-child and :last-child
Select the first or last child of a parent:
li:first-child {
border-top: none;
}
li:last-child {
margin-bottom: 0;
}All lessons in this course
- :hover :focus :active and :visited
- :nth-child and :nth-of-type
- :not() :is() and :where()
- :checked :disabled and Form State Pseudos