What are CSS container queries?
DefinitionCSS container queries are a CSS feature that applies styles to an element based on the size or other properties of its containing element, rather than the size of the browser viewport.
Also known as Container queries
Media queries only let a component respond to the size of the screen. Container queries let developers mark an element as a container with the container-type property and then write @container rules, so a card, for example, can switch to a horizontal layout whenever its parent is wide enough, wherever it appears on the page. They also add container query units, such as cqi and cqw, for sizing relative to the container.
Size container queries have worked in all major browsers since 2023, making them a practical tool for responsive design and reusable web components. Newer additions include style queries, which respond to the values of custom properties set on a container. Container queries now sit alongside CSS Grid and Flexbox as core tools of modern CSS layout.
Topic: Web development
Cite this definition
- APA
What are CSS container queries? (2026, November 22). Glossary. https://glossary.io/css-container-queries/
- MLA
“What Are CSS container queries?” Glossary, Coywolf, 22 Nov. 2026, glossary.io/css-container-queries/.
- Chicago
“What Are CSS container queries?” Glossary. Coywolf. November 22, 2026. https://glossary.io/css-container-queries/.
- HTML link
<a href="https://glossary.io/css-container-queries/">What are CSS container queries?</a>
Published