CSS
Layout, typography, colour and the newer platform features worth switching to.
2026
- Scope component styles with @scope@scope (.card) to (.card-content) keeps a card's img and p rules out of the HTML slotted inside it, without raising specificity.
- Cross-fade a same-document view transitionCross-fade an order list and a detail pane with startViewTransition, and keep the same DOM update for browsers and readers who skip motion.
- Improve paragraph breaks with text-wrap: prettyUse text-wrap: pretty to improve paragraph line breaks without adding manual breaks or nonbreaking spaces.
- Choose a CSS value with if()Use CSS if() to pick a badge background from a custom property, with fallbacks for other tones and older browsers.
- Define Tailwind v4 tokens with @themeMove a custom color and display font from Tailwind’s JavaScript config into CSS and keep using the same utility classes.
- Keep focus rings in a Tailwind upgradeRun the Tailwind v4 upgrade tool and check that renamed utilities preserve the focus treatment from your v3 project.
- Use built-in container queries in Tailwind v4Use named Tailwind container variants to change an event card’s layout and spacing by the width of its slot.
- Animate height: auto with interpolate-sizeUse interpolate-size to transition a disclosure from zero to its content height, with an instant fallback and reduced-motion support.
- Transition to display: none with allow-discreteKeep an element rendered during its opacity fade by transitioning display with allow-discrete, then let display flip to none at the end.
- Animate elements on insertion with @starting-styleGive a newly rendered element a starting opacity with @starting-style so the browser can run an entry transition without a JavaScript timing workaround.
- Position a tooltip with CSS anchor positioningTie a tooltip to its button with anchor-name and position-area, then let position-try-fallbacks flip it below when there is no room above.
- Balance headings with text-wrapUse text-wrap balance to distribute words across short headings, and check the result at narrow widths without adding manual line breaks.
2025
- Style parents with :has()Use a CSS :has() selector with :user-invalid to highlight a field group after a failed validation attempt.
- Style form errors after interactionUse :user-invalid to style a required field after the user leaves it with a changed value or attempts to submit the form.
- Align card rows with CSS subgridShare title, description and action tracks across grid cards so a wrapped heading leaves the content below it aligned.
- Avoid specificity traps in native CSS nestingKeep native CSS nesting predictable by separating an ID from a grouped parent selector that needs a class-level override.
- Generate hover colors with color-mix()Use color-mix() to derive a hover background and border from a single brand color, with a plain-color fallback.
- Make a card respond to its containerUse a container size query to keep the same card stacked in a sidebar and side by side in a wide column.
- Fix mobile 100vh with dvh unitsUse dvh to size a mobile section around browser toolbars, or svh to keep its minimum height stable.
- Use logical properties for RTL layoutsUse logical CSS properties for spacing and offsets that should follow the reading direction.