CSS container-type Property
Description
The container-type property controls whether an element establishes a CSS container for use by container queries and determines how that container's size is measured for those queries. When an element becomes a container, descendant rules written with @container are matched against the container's measured dimensions rather than the viewport or other ancestors. This allows components to adapt their styling based on the size of the element that actually contains them, enabling truly modular, composition-friendly responsive design.
Setting container-type affects how the UA computes the "query box" used by container queries — that is, which axis or dimensions are observed to decide whether a query condition is met. It therefore changes when and how descendant styles change in response to layout changes of the container element. While related, this is conceptually distinct from the containment behaviors controlled by the contain property; container-type specifically enables the element to act as a target for @container queries and to expose its measured size to those queries, whereas contain controls what layout, style, and paint information is isolated for rendering and performance.
You commonly use container-type alongside the container registration properties to make queries more explicit and targeted: the shorthand container can set both the name and the type of a container at once, and container-name lets you reference a specific container when multiple potential containers exist. In practice, pick a stable wrapper element to become a container so you avoid frequent relayouts, and be mindful that enabling container behavior can affect layout passes — it helps decouple component layout from the viewport, but it also introduces a point where the UA must track and re-evaluate styles when that container’s measured dimensions change.
Definition
- Initial value
- normal
- Applies to
- all elements
- Inherited
- no
- Computed value
- as specified
- Animatable
- a color
- JavaScript syntax
- object.style.containerType
Syntax
container-type: size | inline-size | normal
Values
- sizeEstablishes a query container for container size queries on both the inline and block axis in both the inline and block dimensions. Applies layout containment, style containment, and size containment to the container.
- inline-sizeEstablishes a query container for dimensional queries on the inline axis of the container. Applies layout, style, and inline-size containment to the element.
- normalThe element is not a query container for any container size queries, but remains a query container for container style queries.
Example
Browser Support
The following information will show you the current browser support for the CSS container-type property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
