Combinators in CSS
Descendant, child, adjacent and general sibling: four ways to relate elements.
nav a {
text-decoration: none;
}
.menu > li {
list-style: none;
}
h2 + p {
margin-top: 0;
}
p ~ p {
margin-top: 0.75rem;
}
How it works
- A space means any descendant,
>only a direct child. +is the next sibling,~any later sibling.- Sibling combinators are how you space stacked content.
Keywords and builtins used here
menurem
The run, in numbers
- Lines
- 15
- Characters to type
- 125
- Tokens
- 37
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 32 seconds.
Step 3 of 6 in Selectors, step 3 of 26 in Selectors & the box model.