Which CSS property is used to set the width of an element?

The story behind the answer

The CSS property used to set an element's width is `width`.

It accepts values such as fixed lengths (`200px`), percentages (`50%`), and newer responsive units such as `vw`. The exact result depends on the CSS box model: by default, `width` describes the content box, while padding and borders are added outside it. With `box-sizing: border-box`, the declared width includes the content, padding, and border.

A common mix-up is `max-width`, which sets an upper limit rather than directly defining the preferred width. `min-width` sets a lower limit, and `height` controls the vertical dimension. CSS1, published by the W3C in 1996, already defined width and height as core box dimensions, making them among CSS's foundational layout properties.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: