文章与副标题

<hgroup> groups a main heading (<h1>..<h6>) with one or more secondary headings (<p> is also allowed). The browser treats them as a single heading unit for outline purposes.

Designing Accessible Color Systems

A practical guide to contrast ratios, token naming, and dark-mode planning — with real production examples.

Color is the fastest visual signal our brain processes — but it fails us when we rely on it alone. A robust color system pairs every hue with meaning, tests every pair for contrast, and works in both light and dark contexts.

The contrast floor

Every foreground/background combination must meet a minimum contrast ratio. WCAG 2.2 AA requires 4.5:1 for body text and 3:1 for large text (18pt+ bold or 24pt+ regular).

Aa 12.6:1 ✓
Aa 4.7:1 ✓
Aa 2.1:1 ✗

Naming tokens by role

Name variables by what they're for, not what they look like. --color-surface survives a dark-mode flip; --color-bg-white does not.

/* ✅ Role-based (survives theme flip) */
--color-surface: #ffffff;
--color-surface-alt: #f8fafc;
--color-text-primary: #0f172a;

/* ❌ Appearance-based (breaks in dark mode) */
--color-bg-white: #ffffff;
--color-text-black: #000000;

Browser note: older specs let <hgroup> contain multiple heading levels. Modern HTML5.3 says only one heading + supporting <p> elements — use <section> for multiple subsections.