--- name: modern-css description: Proactively apply when creating design systems, component libraries, or any frontend application. Triggers on CSS Grid, Subgrid, Flexbox, Container Queries, :has(), @layer, @scope, CSS nesting, @property, @function, if(), oklch, color-mix, light-dark, relative color, @starting-style, scroll-driven animations, view transitions, anchor positioning, popover, customizable select, content-visibility, logical properties, text-wrap, interpolate-size, clamp, field-sizing, modern CSS, CSS architecture, responsive design, dark mode, theming, design tokens, cascade layers. Use when writing CSS for any web project, choosing layout approaches, building responsive components, implementing dark mode or theming, creating animations or transitions, styling form elements, or modernizing legacy stylesheets. Modern CSS features and best practices for building interfaces with pure native CSS. --- # Modern CSS Pure native CSS for building interfaces — no preprocessors, no frameworks. ## When to Use (and When NOT to) | Use Freely (Baseline) | Feature-Detect First | |---|---| | CSS Grid, Subgrid, Flexbox | `@function`, `if()` (Chrome-only) | | Container Queries (size + style) | Customizable ``, popover, anchor positioning, `field-sizing` | | [references/PERFORMANCE.md](references/PERFORMANCE.md) | `content-visibility`, typography, logical properties, accessibility | | [references/CHEATSHEET.md](references/CHEATSHEET.md) | Quick reference: browser support, legacy→modern patterns, units | ## Sources ### Official Specifications - [CSS Snapshot 2025](https://www.w3.org/TR/css-2025/) — W3C - [CSS Values and Units Level 5](https://www.w3.org/TR/css-values-5/) — `if()`, `random()`, `sibling-index/count()` - [CSS Functions and Mixins Level 1](https://www.w3.org/TR/css-mixins-1/) — `@function`, `@mixin` - [CSS Conditional Rules Level 5](https://www.w3.org/TR/css-conditional-5/) — Scroll-state queries - [CSS Anchor Positioning](https://www.w3.org/TR/css-anchor-position-1/) - [CSS Overflow Level 5](https://www.w3.org/TR/css-overflow-5/) — Scroll markers/buttons ### Browser Vendor Blogs - [CSS Wrapped 2025](https://chrome.dev/css-wrapped-2025/) — Chrome DevRel - [Interop 2025](https://webkit.org/blog/17808/interop-2025-review/) — WebKit - [What's New in Web UI (I/O 2025)](https://developer.chrome.com/blog/new-in-web-ui-io-2025-recap) ### Reference - [MDN Web Docs: CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) - [State of CSS 2025](https://2025.stateofcss.com/en-US/features/) - [What You Need to Know About Modern CSS (2025)](https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-2025-edition/) - [CSS in 2026](https://blog.logrocket.com/css-in-2026/)