Q29: How does native CSS Nesting work and what syntax rules apply?
Native CSS nesting allows nesting child rules inside parent selectors directly in modern browser stylesheets without requiring preprocessors. The & nesting selector explicitly references parent elements.
Native CSS Nesting Example
.card {
background: white;
padding: 1rem;
& .title {
font-size: 1.5rem;
}
&:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
}Nesting child selectors and hover states directly inside parent blocks mirrors Sass workflows natively.
Key Takeaways
Supported natively in modern browsers without preprocessor compilation.
&represents parent selector combinations.
Knowledge Check
What character represents the parent selector inside native CSS nesting blocks?