O'Reilly logo

CSS Pocket Reference, 4th Edition by Eric A. Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

width

Values:

<length> | <percentage> | auto

Initial value:

auto

Applies to:

Block-level and replaced elements

Inherited:

No

Percentages:

Refer to the width of the containing block

Computed value:

For auto and percentage values, as declared; otherwise, an absolute length, unless the property does not apply to the element (then auto)

Description:

Defines the width of an element’s content area, outside of which padding, borders, and margins are added. This property is ignored for inline nonreplaced elements. Negative length and percentage values are not permitted.

Examples:

table {width: 80%;}
#sidebar {width: 20%;}
.figure img {width: 200px;}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required