Quick Wins

Quick Wins

Small CSS techniques you can use in your next project.

  • Create smooth, user-friendly carousels with one property family.

    .container {
      scroll-snap-type: x mandatory;
    }

    Ensures consistent snap-to-slide behavior for carousels.

  • Make in-page navigation feel more polished.

    html {
      scroll-behavior: smooth;
    }

    Creates a better UX for anchor links and navigation menus.

  • Use the :has() pseudo-class to select a parent based on its child.

    .card:has(img) {
      border: 2px solid var(--accent);
    }

    :has() enables powerful parent-child styling in native CSS.

  • Avoid mobile viewport bugs caused by browser UI chrome.

    .hero {
      min-height: 100dvh;
    }

    Prevents content from getting cut off or jumping when mobile address bars expand/collapse.

  • Prevent awkward line breaks in headings with one line of CSS

    h1 {
      text-wrap: balance;
    }

    Creates cleaner, more professional typography with zero effort.

  • Standardize outline styles for better keyboard navigation.

    :focus-visible {
      outline: 2px solid #4a90e2;
      outline-offset: 2px;
    }

    Improves accessibility with clear, uniform focus outlines.

  • Stop your layout from jumping when pages toggle between scrolling and not.

    html {
      scrollbar-gutter: stable;
    }

    Keeps content from shifting horizontally when scrollbars appear/disappear, especially noticeable on desktop layouts.

  • Remove extra space above/below text caused by font metrics.

    h1 {
      text-box-trim: trim-both;
      text-box-edge: cap alphabetic;
    }

    Gives you tighter, more predictable spacing for headings and UI text.

  • Use clamped viewport units in your font sizes for fluid, responsive text.

    h1 {
      font-size: clamp(2rem, 4vw + 1rem, 3rem);
    }

    Ensures text scales smoothly between screen sizes.