CSS container-name Property
Description
The container-name property assigns one or more identifiers to an element so it can be targeted by container query rules. It does not itself change layout or sizing; instead it acts as a label that container query selectors can use to decide which container(s) should be evaluated for conditions. Because the property only names the container, the presence or absence of a name determines whether a named @container rule can match that element as the query container.
When you write container query rules, you can restrict them to containers with a particular label; those named queries will only apply when an ancestor element carries the matching container-name. That behavior works together with the property that determines whether an element actually establishes a query container and what axes it exposes - container-type. There is also a shorthand that lets authors set a container’s name and type together; authors often use that shorthand to keep naming and containment semantics combined for a given element - container.
From an authoring perspective, naming containers is useful for scoping component styles so they only respond to intended query contexts. The property is not inherited and is governed by the normal cascade, so you control which elements become queryable by applying or overriding it on specific container elements. If an element has no name, it can still be used by anonymous (unnamed) container queries; assigning names is primarily a tool for disambiguation and for creating explicit boundaries that prevent unrelated container query rules from matching unexpectedly.
Definition
- Initial value
- none
- Applies to
- all elements
- Inherited
- no
- Computed value
- none or an ordered list of identifiers
- Animatable
- no
- JavaScript syntax
- object.style.containerName
Syntax
container-name: <container-name>
Values
- <container-name>A case-sensitive string that is used to identify the container.
Example
Browser Support
The following information will show you the current browser support for the CSS container-name 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
