CSSCSS · Lesson 15

Modern CSS

Nesting, :has(), container queries, aspect-ratio and clamp().

Video tutorialTrack course · freeCodeCamp
Speed
Next lesson
Watch 00:00 · 1 checkpoints Watch on YouTube More on this topic
Transcript & captions
7/7
  • :has() — style a parent based on its children, e.g. .card:has(img).
  • Native nesting — write child rules inside their parent block.
  • Container queries — @container respond to a component's own width.
  • aspect-ratio — keep media at a fixed shape without padding hacks.
  • clamp(min, ideal, max) — fluid sizing with guard rails.
Try it yourself

Knowledge check

0/1 answered

What does :has() enable?