width
The width property sets the content-box width of an element (or border-box width with box-sizing).
Syntax
width: <length|%|auto|min-content|max-content|fit-content>;
Examples
.container { width: min(100% - 2rem, 1100px); }
.icon { width: 24px; }
Output
Constrains the container to at most 1100px with side gutters and fixes the icon at 24px.
Notes
auto is the default and lets block elements fill available inline space. Combine with max-width for responsive caps. Intrinsic keywords like fit-content size to content. box-sizing changes whether padding/border are included.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |