Skip to main content
Back to News
CSS & DesignMDN Web Docs

CSS Container Queries: Finally Changing How We Build Responsive UIs

Container queries have reached 95%+ browser support. This changes responsive design fundamentally — components that respond to their container, not the viewport.

Muhammad Noman 7 min read
CSSResponsive DesignFrontendWeb Standards

The Problem Container Queries Solve

For years, responsive design has been based on viewport width. A sidebar widget and a full-width hero section both respond to the same media queries — even though they live in completely different contexts.

Container queries change this. Now, a component can respond to the size of its container, not the browser window.

Browser Support in 2026

Container queries have reached 96% global browser support:

  • Chrome: Supported since v105
  • Firefox: Supported since v110
  • Safari: Supported since v16
  • Edge: Supported since v105

With 96% support, there's no reason not to use them in production.

How Container Queries Work

The Old Way (Media Queries)

Media queries look at the viewport:

  • At 768px viewport width, change the layout
  • Problem: A card in a sidebar and a card in the main content both change at 768px
  • This doesn't make sense — they have different available space

The New Way (Container Queries)

Container queries look at the parent element:

  • When the container is less than 400px wide, stack vertically
  • When the container is more than 400px wide, display horizontally
  • The same component adapts perfectly whether it's in a sidebar, a grid, or full-width

Practical Examples

Product Cards

A product card component that:

  • In a 3-column grid: Shows image on top, text below
  • In a sidebar: Shows small thumbnail with text beside it
  • In full-width: Shows large image left, details right
  • All with one component — no media query breakpoints needed

Navigation Components

A nav component that:

  • In a wide header: Shows horizontal links
  • In a mobile drawer: Shows stacked vertical links
  • In a footer: Shows multi-column layout
  • All responsive to their container, not the viewport

Dashboard Widgets

A stats widget that:

  • In a large card: Shows full chart with legend
  • In a small card: Shows just the number and trend arrow
  • In a grid item: Shows compact chart without labels
  • Automatically adapts without custom CSS per location

Real Impact on Development

Less CSS Overall

  • No more writing breakpoint-specific styles for every context
  • One component definition handles all layouts
  • Reduces CSS file sizes by 30-50% in complex projects

Better Component Reusability

  • Components truly work anywhere without modification
  • Design systems become more flexible
  • Handoff between designers and developers improves

Easier Maintenance

  • Change the grid layout? Components adapt automatically
  • Add a sidebar? Existing components just work
  • Redesign a section? Components respond to their new context

Getting Started

Basic Syntax

The key CSS properties:

  • container-type: inline-size — Defines an element as a container
  • @container (min-width: 400px) { } — Query the container's width
  • container-name: sidebar — Name containers for targeted queries

My Recommendation

Start using container queries today for:

  1. Card components
  2. Navigation elements
  3. Form layouts
  4. Dashboard widgets
  5. Any component used in multiple contexts

The Future of Responsive Design

Container queries are the biggest CSS advancement since Flexbox and Grid. They finally make truly reusable components possible. If you're building a website in 2026 and not using container queries, you're missing out on simpler, more maintainable code.

Have a Project in Mind?

Let's discuss how I can build a practical solution for your business.

Get in Touch