CSS width Property


CSS's width property is used to specify the width of text and images. The width of text and images can be specified in pixels (px), percentages (%), centimetres (cm), and other units.

Padding, borders, and margins are not included in the width property. The min-width and max-width properties override the width property.

The width property sets the width of the content area by default, but if the box-sizing property is set to border-box, it sets the width of the border area.

Syntax

Example

Preview

Property Values

Value Description
auto The default value. The width is calculated by the browser.
length Defines the width in pixels, centimeters, and so on. Learn more about length units.
% Defines the width of the containing block in percentages.
initial This property is set to its default value.
inherit This property is inherited from its parent element.

Supported Browsers

Property Chrome Firefox Safari Edge / IE Opera
width 1.0 1.0 1.0 4.0 3.5