CSS Articles

    Modern CSS techniques, layout tricks, animations, and design system patterns for the modern web.

    How to use the advanced CSS attr() function for types and units
    CSS7 min

    How to use the advanced CSS attr() function for types and units

    attr(data-color color, #333) feeding straight into background-color sounds like it already ships, but as of early 2026 it's spec-only. Here's what attr() actually does today, and what's coming.

    Editor: Paul Radford
    Jul 26, 2026
    selectorsfrontend
    Animating to height auto using CSS interpolate-size
    CSS8 min

    Animating to height auto using CSS interpolate-size

    height: auto was never a number the browser could interpolate toward, which is exactly why it never animated at all. These two features finally give the engine something concrete to target.

    Editor: Paul Radford
    Jul 20, 2026
    animationlayoutfrontend
    Serving responsive background images with the CSS image-set function
    CSS7 min

    Serving responsive background images with the CSS image-set function

    Three separate min-resolution media query blocks plus an @supports check for WebP used to be needed just to keep background images in sync. image-set() resolves all of that on its own now.

    Editor: Paul Radford
    Jul 2, 2026
    Removing wrapper nodes from CSS Grid and Flexbox with display: contents
    CSS8 min

    Removing wrapper nodes from CSS Grid and Flexbox with display: contents

    Grid and Flexbox both expect their items to be direct children of the container, but semantic HTML forces wrapper elements in between. display: contents removes the wrapper's box, not its markup.

    Editor: Paul Radford
    Jul 2, 2026
    layoutgrid
    How to use CSS math functions round, mod, and rem for layout calculations
    CSS7 min

    How to use CSS math functions round, mod, and rem for layout calculations

    Rounding a fluid width to the nearest multiple of 8px used to require a resize listener writing values back to a custom property. These math functions run natively at layout time instead.

    Editor: Paul Radford
    Jul 2, 2026
    layout
    CSS @when/@else: Writing Conditional Styles Without JavaScript
    CSS7 min

    CSS @when/@else: Writing Conditional Styles Without JavaScript

    Testing three separate conditions today means three conditional blocks stitched together, or a JavaScript fallback filling the gaps. @when/@else isn't shipping yet, but it's worth planning for.

    Editor: Paul Radford
    Jul 2, 2026
    selectorsfrontend
    Adapting UI components for Windows High Contrast mode using forced-colors
    CSS8 min

    Adapting UI components for Windows High Contrast mode using forced-colors

    A styled checkbox that renders as a completely empty box is almost always a Windows contrast theme your CSS never accounted for. Here's how to detect that mode and restore visibility.

    Editor: Paul Radford
    Jul 2, 2026
    Custom List Markers with @counter-style: Beyond Bullet Points
    CSS7 min

    Custom List Markers with @counter-style: Beyond Bullet Points

    Faking custom bullets with generated content strips list position entirely from screen reader announcements. @counter-style plugs into list-style-type without losing that native semantics.

    Editor: Paul Radford
    Jun 28, 2026
    typographyfrontendlists