Skip to content

Frontend & UI

Modern CSS and the web platform

A mental model for layout, container queries and design tokens, then letting the Popover API, anchor positioning and native dialogs replace a lot of JavaScript.

5 parts46 min readUpdated Sep 21, 2026

Parts

  1. Part 1

    A Mental Model for CSS Layout: From Normal Flow to Flexbox and Grid

    Normal flow, block vs inline, flexbox (one dimension, content-out) vs grid (two dimensions, layout-in), intrinsic sizing, and why min-width: 0 rescues overflowing flex items — so you write layout from understanding instead of trying properties until it works.

    7 min

  2. Part 2

    Container Queries and Modern Responsive Design: Components That Know Their Own Width

    Why viewport media queries fall short for reusable components, how to use container-type, named containers and cqi units, how to combine them with clamp() and :has(), plus a complete responsive card and a fallback strategy.

    5 min

  3. Part 3

    Design Tokens and Theming with CSS Custom Properties: From Raw Colors to Dark Mode

    Splitting tokens into three tiers, naming by purpose, building light/dark themes with prefers-color-scheme plus a user override without a flash, color-scheme, mapping tokens into Tailwind v4's @theme, contrast checks and common mistakes.

    7 min

  4. Part 4

    Platform First: Popover API, CSS Anchor Positioning and View Transitions Replace a Lot of UI JavaScript

    In 2026 the browser ships primitives that used to require Floating UI, Radix or an animation library. This post covers popover, invoker commands, anchor positioning and View Transitions: what they do, how to combine them, where support really stands, and where a library is still the right call.

    19 min

  5. Part 5

    Accessible Modal Dialogs: Using the Native dialog Element Properly

    From showModal(), the top layer and ::backdrop to focus management, labelling, scroll locking, backdrop clicks and nested dialogs — plus a small React component and how to test it with a keyboard and a screen reader.

    8 min

Series review

0/10 answered · 0 correct

10 questions drawn from the parts of this series. Answers here count toward each post's own quiz.

  1. Question 1 of 10IntermediateA flex row has an avatar and a flex: 1 text block holding a white-space: nowrap; text-overflow: ellipsis title, yet the title still pushes the row wider than its container. Why, and what is the fix?
  2. Question 2 of 10StarterHow does the post suggest quickly telling flexbox and grid apart?
  3. Question 3 of 10StarterA card using viewport media queries gets squeezed into a narrow text column when placed in a 280px sidebar on a 1440px screen. Why do container queries fix this?
  4. Question 4 of 10IntermediateYou set container-type: inline-size on a flex item with no flex-grow and use @container to restyle that same element. Which two problems can occur?
  5. Question 5 of 10IntermediateWhy should components use semantic tokens (--color-accent) rather than primitives (--blue-600) directly?
  6. Question 6 of 10IntermediateA user chose the dark theme but sees a light flash every time the page opens. What is the cause and the fix?
  7. Question 7 of 10IntermediateWhen should you use <dialog> with showModal() instead of popover?
  8. Question 8 of 10IntermediateNow that platform primitives exist (popover, anchor positioning), how should a team decide between native and a library like Radix or Floating UI?
  9. Question 9 of 10IntermediateIn React you pass the open prop to <dialog> to open a modal. What actually happens?
  10. Question 10 of 10IntermediateWhere should initial focus go in a "Delete project" confirmation dialog, and why?

Other series

Series