width
Sets the width of an element. It can be defined in absolute units like pixels or relative units like percentages.
It is documented as part of the CSS Box Sizing specification.
Syntax
/* Usage Example */
.container {
width: 100%;
max-width: 1200px;
/* responsive width was a max limit */
}
/* Syntax */
width: auto;
width: length-percentage;
width: min-content;
width: max-content;
width: fit-content;
width: calc-size;
width: anchor-size;
/* Global values */
width: inherit;
width: initial;
width: revert;
width: revert-layer;
width: unset;
width Browser support
Widely available
Since
2015 96% global usage
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.
1+
1+
1+
12+