css.properties

width

The width property sets the width of an element.

Formal Syntax

auto | <length-percentage [0,∞]> | min-content | max-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain

See specification

Logical Property Group

This property belongs to the size logical property group, which includes:

Browser Support

standard | MDN · Spec

FeatureChromeFirefoxSafariEdge
width11112
anchor-size12514726125
auto11112
fit-content46941179
fit-content_function91
is_animatable2616712
max-content46661179
min-content46661179
stretch1381467138

Behind a Flag

Some browsers require enabling a flag or preference:

  • width: fit-content_function — firefox: #layout.css.fit-content-function.enabled (since 91)

Related Properties