CSS container-name Property

Beginner
2 examples
Updated: Nov 2026

Definition and Usage

The container-name property assigns one or more names to a query container. Named queries avoid matching the wrong ancestor.

CSS Syntax

syntax.css
.sidebar {
  container-type: inline-size;
  container-name: sidebar;
}

Property Values

ValueEffectTry it
noneNo custom nameTry it
One or more custom ident namesTry it

CSS Examples

Basic use

example.css
.sidebar {
  container-type: inline-size;
  container-name: sidebar;
}
Try It Yourself

Browser Support

container-name is a CSS property.

✓ CSS

container-name

Check support for your audience.

92% Modern browsers
Google Chrome Recent
Full support
Mozilla Firefox Recent
Full support
Apple Safari Recent
Full support
Microsoft Edge Recent
Full support
container-name Modern support

Bottom line: Prefer progressive enhancement when support varies.

Frequently Asked Questions

The container-name property assigns one or more names to a query container. Named queries avoid matching the wrong ancestor.
Use it with progressive enhancement and check current browsers for edge cases.
Read the definition, try the first example, then compare related properties.
Sometimes. Prefer modern properties when browser support meets your audience.
Open the Try it demos and change one value at a time.

Next: container-type

Continue with container-type.

container-type →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

2 people found this page helpful