CSS nesting
noun
say it: “SEE-ESS-ESS NEST-ing” /ˌsiːɛsˈɛs ˈnɛstɪŋ/
Writing CSS rules inside another rule, so a component's parts, its states and its media queries sit together in one block.
What is CSS nesting?
CSS nesting lets you write rules for child elements inside a parent rule, keeping related styles together.
.card {
padding: 16px;
h3 { margin-top: 0; }
&:hover { box-shadow: 0 2px 8px #0002; }
}
In a sentence
- “With CSS nesting, the game card's heading, its button and its hover state all live inside one .game-card block.”
Level: Freelancer · More CSS terms at this level
Updated