CSS Articles

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

    Serving responsive background images with the CSS image-set function
    CSS7 min

    Serving responsive background images with the CSS image-set function

    While the HTML <picture> element handles responsive inline images, CSS background images have historically required complex media queries. The image-set() function allows the browser to automatically select the most appropriate background image based on screen resolution and format support.

    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

    The display: contents property allows an element to visually disappear while its children participate directly in the parent's Grid or Flexbox layout. This article breaks down how it works, when to use it for semantic HTML, and the historical accessibility bugs you need to know.

    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

    CSS now supports advanced mathematical functions like round(), mod(), and rem() natively. This article explains how to use these functions to calculate dynamic grid tracks, snap typography to a baseline grid, and avoid complex JavaScript resize listeners.

    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

    Explore the new CSS @when and @else at-rules that bring conditional logic directly into stylesheets. This article covers practical use cases for creating state-dependent styles, responsive behavior without media queries, and theme switching that actually makes sense.

    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

    Windows High Contrast mode forces a user-defined color palette on web pages, often breaking custom UI components like styled checkboxes or buttons. The forced-colors media query allows developers to detect this mode and apply specific CSS to 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

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

    Editor: Paul Radford
    Jun 28, 2026
    typographyfrontendlists
    aspect-ratio: The Property That Changes How You Think About Responsive Layouts
    CSS7 min

    aspect-ratio: The Property That Changes How You Think About Responsive Layouts

    aspect-ratio: The Property That Changes How You Think About Responsive Layouts

    Editor: Paul Radford
    Jun 28, 2026
    layoutfrontend
    Controlling Scroll Boundaries with overscroll-behavior
    CSS7 min

    Controlling Scroll Boundaries with overscroll-behavior

    Controlling Scroll Boundaries with overscroll-behavior

    Editor: Paul Radford
    Jun 28, 2026
    scrollfrontendlayout