<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov" -->

---
title: Stop Treating CSS Container Queries Like Traditional...
description: CSS container queries remain widely underused despite roughly 94% browser support, largely because developers treat them like media queries. Media queries look...
canonical: https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine | daily.dev
og:description: CSS container queries remain widely underused despite roughly 94% browser support, largely because developers treat them like media queries. Media queries look...
og:url: https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov
og:image: https://api.daily.dev/og/posts/opbOrjqoV.png
og:image:alt: Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine

**[Smashing Magazine](https://daily.dev/sources/smashing)** · 12 min read · 8 upvotes · 0 comments

## Summary

CSS container queries remain widely underused despite roughly 94% browser support, largely because developers treat them like media queries. Media queries look outward at the viewport for 'macro' page-level layout, while container queries look inward at a component's own container size for 'micro' component-level layout. The piece covers container query units (cqi, cqw, cqb), fluid typography scoped to a container instead of the viewport, a flexbox-wrap-detection technique using nested containers, and three caveats: needing an extra wrapper element (a container can't query itself), size-type containers collapsing to 0px without explicit height, and containers being unable to accept custom-property values in their conditions. The guidance offered is to use container queries for reusable components appearing in multiple layout contexts and media queries for page-level, viewport-tied elements.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://smashingmagazine.com/2026/09/stop-treating-css-container-queries-traditional-media-queries>

## Questions this post answers

### Why does my card component's layout break when I place it inside a narrow sidebar even though my media query still matches?

Media queries only check the viewport width, not the space actually available to the component, so a min-width media query fires based on the full screen size even when the component sits in a 300px-wide sidebar on a 1920px screen, causing overflow or cramped content. Container queries fix this by checking the actual space allocated to the component's container instead of the viewport.

_When component layouts break across different contexts, daily.dev surfaces practical CSS patterns like container queries for exactly this problem._

### Why doesn't my CSS container query work when I put container-type on the same element I'm styling with @container?

A container cannot query itself because that creates a circular dependency: querying a .card element while also trying to change that same element's display based on its own size is logically an infinite loop. The fix is adding an extra wrapper element around the component, defining container-type on the wrapper, and then querying that wrapper to adjust the child's styles.

_Debugging container query quirks like this is easier when daily.dev keeps CSS deep-dives close at hand._

### Why does my container collapse to 0px height when I use container-type: size in CSS?

Setting container-type: size makes the browser calculate the container's dimensions without looking at its children's content, so without an explicit height, min-height, or aspect-ratio, the container collapses to 0px even though it has content inside. Querying by inline-size instead avoids this collapse unless you specifically need to query the block (vertical) size.

_Knowing these container-query pitfalls up front helps developers ship responsive CSS on daily.dev's radar without the layout surprises._

## Similar posts on daily.dev

- [CSS Container Queries](https://daily.dev/posts/css-container-queries-iq9qajosu) · Flavio Copes · 24 upvotes · 0 comments
- [Container queries in 2026: Powerful, but not a silver bullet](https://daily.dev/posts/container-queries-in-2026-powerful-but-not-a-silver-bullet-zamknhyli) · LogRocket · 7 upvotes · 0 comments
- [Container Queries and Units in Action](https://daily.dev/posts/container-queries-and-units-in-action-fngqaphz7) · OddBird · 6 upvotes · 0 comments
- [How to Build Responsive Designs and Scroll Effects with CSS Container Queries](https://daily.dev/posts/how-to-build-responsive-designs-and-scroll-effects-with-css-container-queries-xw53ucqmc) · freeCodeCamp · 10 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#ui-design](https://daily.dev/tags/ui-design)

[View this post on daily.dev](https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine","url":"https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov"},"datePublished":"2026-09-16T15:30:35.461Z","dateModified":"2026-09-16T15:39:01.685Z","description":"CSS container queries remain widely underused despite roughly 94% browser support, largely because developers treat them like media queries. Media queries look...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b10e36ed90975171f21cae36164f40eb?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b10e36ed90975171f21cae36164f40eb?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Smashing Magazine","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Smashing Magazine","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/smashing","url":"https://daily.dev/sources/smashing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":8},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css,ui-design","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Smashing Magazine","item":"https://daily.dev/sources/smashing"},{"@type":"ListItem","position":3,"name":"Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov#faq","mainEntity":[{"@type":"Question","name":"Why does my card component's layout break when I place it inside a narrow sidebar even though my media query still matches?","acceptedAnswer":{"@type":"Answer","text":"Media queries only check the viewport width, not the space actually available to the component, so a min-width media query fires based on the full screen size even when the component sits in a 300px-wide sidebar on a 1920px screen, causing overflow or cramped content. Container queries fix this by checking the actual space allocated to the component's container instead of the viewport. When component layouts break across different contexts, daily.dev surfaces practical CSS patterns like container queries for exactly this problem."}},{"@type":"Question","name":"Why doesn't my CSS container query work when I put container-type on the same element I'm styling with @container?","acceptedAnswer":{"@type":"Answer","text":"A container cannot query itself because that creates a circular dependency: querying a .card element while also trying to change that same element's display based on its own size is logically an infinite loop. The fix is adding an extra wrapper element around the component, defining container-type on the wrapper, and then querying that wrapper to adjust the child's styles. Debugging container query quirks like this is easier when daily.dev keeps CSS deep-dives close at hand."}},{"@type":"Question","name":"Why does my container collapse to 0px height when I use container-type: size in CSS?","acceptedAnswer":{"@type":"Answer","text":"Setting container-type: size makes the browser calculate the container's dimensions without looking at its children's content, so without an explicit height, min-height, or aspect-ratio, the container collapses to 0px even though it has content inside. Querying by inline-size instead avoids this collapse unless you specifically need to query the block (vertical) size. Knowing these container-query pitfalls up front helps developers ship responsive CSS on daily.dev's radar without the layout surprises."}}]}
```

