learn.web Back to the curriculum ↗

HTML / CSS / JavaScript / 03

CSS as an interface language

Practice cascade layers, nesting, style queries, anchor positioning, color spaces, and resilient fallbacks.

Time
95 min
Mode
Learn → Make → Check
Path
Modern Web Platform

By the end, you can…

Modern CSS is a capability ladder

New CSS does not require an all-or-nothing browser target. Write the dependable layout first, then add a sharper behavior inside @supports. Browsers that understand the feature get the enhancement; the rest ignore it without breaking the task.

Anchor positioning is a good example. A popover can have a normal fixed or absolute fallback, then position itself relative to its trigger when anchor-name and position-area are supported. The relationship lives in CSS instead of JavaScript coordinates.

Motion should explain change

View transitions and scroll-driven animations can communicate continuity, hierarchy, and progress. They become noise when they animate everything or delay control. Define the information the motion carries before choosing an effect.

Use prefers-reduced-motion to remove nonessential movement, not merely shorten it. Verify that content order, focus, and task completion make sense with all animation disabled.

Working example
.trigger { anchor-name: --tip; }
.tip { position: absolute; }
@supports (position-area: block-start) {
  .tip {
    position-anchor: --tip;
    position-area: block-start;
  }
}

Your studio task

Make — Anchor a callout, animate one reveal, and add a deliberate fallback.

  1. Choose one tooltip or callout with brittle JavaScript coordinates.
  2. Create a simple non-anchored fallback.
  3. Enhance it with anchor positioning and a position fallback.
  4. Disable the feature and reduced-motion animations to verify the task.
Definition of done

The core task still works in a browser that ignores every enhancement.

Open the interactive lesson with its workspace ↗

Knowledge check

What belongs inside @supports?
  1. The only version of essential content
  2. An enhancement whose fallback already works
  3. All design tokens
Reveal answer (B)

Feature queries are ideal for enhancements layered over a complete baseline.

In a browser without position-area support, what happens?
  1. The rule is ignored and the fallback stays
  2. The page fails to load
  3. The browser downloads a polyfill
Reveal answer (A)

Unsupported declarations are ignored, which is exactly what makes progressive enhancement work.