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

  • Tutorial:CSS @scope: Component-Level Style Isolation

    Limit where selectors match, with donut scopes and proximity.
    Use CSS @scope to keep component styles inside a root, stop them at a donut-scope limit, and let scope proximity fix nested themes.
    Published at:
    Categories:CSS
    Estimated reading time:8 min read
  • 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:The :open Pseudo-Class for <details>, <dialog> and <select>

    Style anything that opens, selects included, with one pseudo-class.
    Style the open state of <details>, <dialog> and <select> with the CSS :open pseudo-class. Compare it with [open], :popover-open and :modal, with fallbacks.
    Published at:
    Categories:CSS
    Estimated reading time:11 min read
  • Tutorial:CSS Custom Highlight API: ::highlight() for Search Results

    Highlight search matches with CSS without touching the DOM.
    Highlight search results with the CSS Custom Highlight API: ::highlight(), CSS.highlights, StaticRange, priority, accessibility and a mark fallback.
    Published at:
    Categories:CSS
    Estimated reading time:14 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