liveBook · Manning

Chapter 4: Vanilla CSS

What you will learn in chapter 4 of Vanilla Web

The chapter introduces direct use of modern CSS for Vanilla Web apps and gives principles for keeping styles maintainable.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces direct use of modern CSS for Vanilla Web apps and gives principles for keeping styles maintainable.

Key terms: Vanilla CSS, custom properties, Cascade Layers, container queries, preprocessor, semantic classes, UI role, component, selectors

4.1 Maintainable and modular CSS

This section counters the idea that Vanilla CSS requires outdated workarounds and introduces modern CSS as a practical basis for maintainable stylesheets.

Key terms: Vanilla CSS, modern CSS, Baseline

4.1.1 Cascade Layers

This section explains how cascade layers make CSS override order explicit, including how to keep third-party styles from unexpectedly overriding components.

Key terms: cascade layers, reset, base, components, utilities, third-party CSS, layer

4.1.2 Custom properties (variables)

Explains how CSS custom properties hold reusable design values and how scoped overrides create themes.

Key terms: custom properties, variables, var(id), :root, inherit, theming, tokens, html, container, media queries

4.1.3 Container queries and units

This section explains how container queries and related CSS units make component layouts respond to their surroundings rather than only to the viewport.

Key terms: container queries, media queries, viewport, container-type, inline-size, size, @container, container names, container units, cqw

4.1.4 Nested selectors

This section explains how CSS nesting organizes related selectors and reduces repetition.

Key terms: CSS nesting, nested selectors, parent selector, specificity

4.1.5 New pseudo-selectors

Introduces four modern CSS pseudo-selectors for writing concise, intentional styles, including their specificity, accessibility, and performance implications.

Key terms: :is(), :where(), specificity, :has(), parent selector, :focus-visible, focus styles, keyboard navigation

4.1.6 Modern CSS units

This section explains how modern CSS units size layouts and typography relative to the viewport, containers, text, and writing mode, and how to choose units consistently.

Key terms: relative units, absolute units, px, %, em, rem, vh, vw, dvh, lvh

4.2 Modern Layout

Introduces modern CSS layout choices for clean, semantic Vanilla Web pages and distinguishes them from legacy layout techniques.

Key terms: Flexbox, grids, subgrids, absolute positioning, float and clear, semantic HTML, divitis, classitis, stylesheets

4.2.1 1D layout with Flexbox

This section explains how Flexbox lays out items along one axis and why it is useful for adaptable UI components.

Key terms: Flexbox, flex container, flex items, justify-content, align-items, UI components, complex page grids, growth and shrink values, media queries

4.2.2 2D layout with grids

This section explains how CSS Grid creates responsive two-dimensional layouts and how subgrid keeps nested layouts aligned with their parent.

Key terms: CSS Grid, Flexbox, tracks, grid container, named areas, minmax, fractional units, auto-fit, auto-fill, container queries

4.3 Animations

Introduces platform-native animation as the Vanilla Web approach and gives guidance on motion preferences and performance.

Key terms: Vanilla Web, prefers-reduced-motion, transform, opacity, compositor, layout thrashing, DevTools

4.3.1 Transitions

This section explains how CSS transitions animate state changes and where they are useful.

Key terms: CSS transitions, duration, delay, easing, micro-interactions

4.3.2 Keyframe animations

This section introduces keyframe animations as a way to create multi-step CSS motion that can loop when a simple transition is insufficient.

Key terms: keyframe animations, @keyframes, animation shorthand, transition

4.3.3 Page transitions

Introduces built-in view transitions and the different ways SPAs and MPAs use them.

Key terms: View Transitions API, SPAs, document.startViewTransition, MPAs, @view-transition, same-origin navigations

4.3.4 Scroll-driven animations

Introduces scroll-driven animations as motion tied to scrolling, with a brief distinction between scroll and view timelines.

Key terms: scroll-driven animations, animation-timeline, scroll(), view(), view-timelines

4.4 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 3: The user interface Chapter 5: Vanilla JavaScript →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.