Skip to main content

Harshal V. LADHE

Progressive Enhancement in CSS

Building on broadly supported CSS first, with readable fallbacks and @supports guards, then layering on newer features for browsers that support them.

Content tagged progressive-enhancement

  • Snippet::playing and :paused: Style Media by Playback State

    Style audio and video players from their playback state.
    Style audio and video by playback state with CSS :playing, :paused, :buffering and :muted, plus :has() patterns and a JavaScript fallback.
    Published at:
    Categories:CSS
    Estimated reading time:7 min read
  • Tutorial:contrast-color(): Automatic Readable Text on Any Background

    Let CSS choose readable white or black text automatically.
    Use CSS contrast-color() to pick white or black text for any background colour: how the spec defines it, custom properties and brand colours, buttons and tags, pairing with light-dark(), mid-tone limits, and an @supports fallback.
    Published at:
    Categories:CSS
    Estimated reading time:10 min read
  • Tutorial:Animate and Type-Check CSS Variables with @property

    Give CSS custom properties real types so they animate.
    Register CSS custom properties (CSS variables) with @property — a syntax, an inherits rule and an initial value — so they animate in transitions and keyframes, fall back safely on invalid values and always have a default. Covers rotating gradients, counting numbers and per-axis motion, CSS.registerProperty(), performance, browser fallbacks and common pitfalls.
    Published at:
    Categories:CSS
    Estimated reading time:8 min read
  • Tutorial:Animating height: auto in CSS with interpolate-size

    Animate height to auto in pure CSS, no JavaScript.
    Animate height: auto in CSS with interpolate-size and calc-size(): smooth accordions and details panels without JavaScript, plus fallbacks and reduced motion.
    Published at:
    Categories:Animations
    Estimated reading time:9 min read
  • Tutorial:Auto-Growing Textareas with CSS field-sizing: content

    Auto-grow textareas with one line of CSS, no JavaScript.
    Make a textarea grow and shrink with its text using CSS field-sizing: content: no scrollHeight JavaScript, plus size limits, fallbacks and browser support.
    Published at:
    Categories:CSS
    Estimated reading time:8 min read