Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14
Chapter 3

Modern CSS 2025 & Summary

The newest CSS features and the key takeaways for writing modern, maintainable stylesheets.


Modern CSS 2025

FeatureWhat it does
CSS NestingNative nesting — no Sass needed
Container QueriesRespond to the parent container's width
:has()The long-awaited parent selector
CSS Cascade Layers@layer for managing specificity
Scroll-driven animationsZero JavaScript
CSS Custom PropertiesDesign tokens
oklch()Wide-gamut perceptual colour
text-wrap: balanceSmart headings

Key Takeaways

  • Separate style from content — use external CSS.
  • box-sizing: border-box — always reset it globally.
  • Use rem / em over px for scalable layouts.
  • Flexbox for 1D layouts, Grid for 2D layouts.
  • animation-fill-mode: both for smooth entry/exit.
  • steps() for sprite-sheet frame control.
  • Mobile-first with min-width media queries.
  • Validate at jigsaw.w3.org/css-validator.

Activity — complete the code

Complete the code correctly to mark this lesson as complete automatically.

Complete the three modern CSS 2025 features.

/* Parent selector */
div:(img) { border: 1px solid; }
 
/* Cascade layers */
@ reset, base, components;
 
/* Smart headings */
h1 { text-wrap: ; }