Modern CSS & HTML
Write CSS and HTML with current platform features. Prefer native materials over legacy hacks and unnecessary JavaScript.
Composition with other skills
- This skill owns native implementation choices.
fluid-design owns interaction feel when physics, interruption, or gestures exceed CSS.
semantic-html-first owns element and ARIA boundaries.
- If a native CSS/HTML feature can meet the requirement with acceptable support, use it.
Browser support policy
Target features available in both WebKit (Safari) and Blink (Chrome/Edge) unless the task explicitly allows a single-engine experiment.
- Widely available in both engines: ship as default.
- Newly available in both: ship with
@supports / progressive enhancement.
- Single-engine or unstable: mention as optional; provide a cross-engine path.
Do not hardcode volatile global percentage figures in recommendations. Re-check support when unsure, and encode the decision as "both engines / enhance / fallback".
Core defaults
HTML
- Use native elements (
button, a, details, dialog, select, form controls) before ARIA widgets.
- Prefer semantic structure (
main, nav, section, headings) over div soup.
- Use Popover API + CSS Anchor Positioning before custom floating stacks when support allows.
Layout
gap over margin hacks; inset over four physical offsets; aspect-ratio over padding hacks.
100dvh for mobile full-height; logical properties for direction-aware spacing.
- Container queries for component responsiveness; range syntax for media queries.
subgrid, grid-template-areas, position: sticky, scroll snapping when they replace JS.
Colour and theme
- Build palettes in
oklch().
- Derive states with
color-mix() and relative colour syntax.
- Prefer
light-dark() with color-scheme over duplicated scheme blocks.
Motion
- Animate
translate, rotate, scale, and opacity preferentially.
- Use
@starting-style and transition-behavior: allow-discrete for entry/exit where supported.
- Prefer CSS scroll-driven timelines over Intersection Observer class toggles when support allows.
- Defer to
fluid-design for springs, gestures, and interruptible physics.
Review checklist
References
- Read Task recipes when implementing a matching pattern.
- Read Feature notes when choosing a feature or fallback.
Load only the reference relevant to the current decision.
1---2name: modern-css-html3description: Choose native CSS and HTML features, assess browser support, or replace legacy workarounds with progressive enhancement.4license: MIT5---67# Modern CSS & HTML89Write CSS and HTML with current platform features. Prefer native materials over legacy hacks and unnecessary JavaScript.1011## Composition with other skills1213- This skill owns **native implementation choices**.14- `fluid-design` owns **interaction feel** when physics, interruption, or gestures exceed CSS.15- `semantic-html-first` owns **element and ARIA boundaries**.16- If a native CSS/HTML feature can meet the requirement with acceptable support, use it.1718## Browser support policy1920Target features available in both **WebKit (Safari)** and **Blink (Chrome/Edge)** unless the task explicitly allows a single-engine experiment.2122- **Widely available in both engines:** ship as default.23- **Newly available in both:** ship with `@supports` / progressive enhancement.24- **Single-engine or unstable:** mention as optional; provide a cross-engine path.2526Do not hardcode volatile global percentage figures in recommendations. Re-check support when unsure, and encode the decision as "both engines / enhance / fallback".2728## Core defaults2930### HTML3132- Use native elements (`button`, `a`, `details`, `dialog`, `select`, form controls) before ARIA widgets.33- Prefer semantic structure (`main`, `nav`, `section`, headings) over div soup.34- Use Popover API + CSS Anchor Positioning before custom floating stacks when support allows.3536### Layout3738- `gap` over margin hacks; `inset` over four physical offsets; `aspect-ratio` over padding hacks.39- `100dvh` for mobile full-height; logical properties for direction-aware spacing.40- Container queries for component responsiveness; range syntax for media queries.41- `subgrid`, `grid-template-areas`, `position: sticky`, scroll snapping when they replace JS.4243### Colour and theme4445- Build palettes in `oklch()`.46- Derive states with `color-mix()` and relative colour syntax.47- Prefer `light-dark()` with `color-scheme` over duplicated scheme blocks.4849### Motion5051- Animate `translate`, `rotate`, `scale`, and `opacity` preferentially.52- Use `@starting-style` and `transition-behavior: allow-discrete` for entry/exit where supported.53- Prefer CSS scroll-driven timelines over Intersection Observer class toggles when support allows.54- Defer to `fluid-design` for springs, gestures, and interruptible physics.5556## Review checklist5758- [ ] Is there a native HTML element for this control?59- [ ] Can layout/colour/motion be done in CSS without a library?60- [ ] Are colours tokens/`oklch` rather than one-off hex?61- [ ] Are fallbacks expressed with `@supports` where needed?62- [ ] Does reduced-motion get a real alternative path?63- [ ] Are physical left/right properties avoided for direction-sensitive UI?64- [ ] If JS remains, is it covering a gap CSS/HTML cannot?6566## References6768- Read [Task recipes](references/recipes.md) when implementing a matching pattern.69- Read [Feature notes](references/features.md) when choosing a feature or fallback.70Load only the reference relevant to the current decision.