Module lessons (1/4)
Native CSS Nesting (&) & Form State Styling with :has()
Write clean nested component rules natively and highlight error states or empty lists with zero JavaScript.
What you'll learn in this lesson
- Group related component rules natively in CSS without Sass using
&CSS Nesting. - Understand what CSS nesting cannot do cleanly (never glue suffix fragments like
&-titleexpecting BEM concatenation—&behaves like:is(...)matching elements directly!). - Build zero-JS stateful form rows using
:has(:user-invalid)and empty-state banners with:empty.
Overview
All evergreen browsers now parse nested CSS directly—shrinking component sheets and eliminating repetitive class prefixes cleanly:
In Sass, developers often wrote .card { &__title { ... } } to string-concatenate into .card__title. Native CSS & represents the parent selector object, NOT string concatenation! Writing &__title compiles strictly into .card__title only when unsupported string hacks are avoided—so always use clean child class names (& .title, & > h2,…
Sections covered in this lesson
- 1Native CSS Nesting (
&) Without Any Build Step - 2Reactive Forms Without JavaScript Using
:user-invalid+:has()
Unlock "Native CSS Nesting (&) & Form State Styling with :has()" and the full Modern HTML & CSS curriculum
Write clean nested component rules natively and highlight error states or empty lists with zero JavaScript.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.