Name

width

Values:

<length> | <percentage> | auto | inherit

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 specified; otherwise, an absolute length, unless the property does not apply to the element (then auto).

Description:

This 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;}

Supported by:

Firefox, Internet Explorer, Opera, Safari.

Note:

In IE6 and earlier, width is treated as a minimum width, not a fixed width.

Get CSS Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.