CSS Property - Width

Value: <length> | <percentage> | auto
Initial: auto
Applies to: block-level and replaced elements
Inherited: no
Percentage values: refer to parent element's width

The CSS property "width" can be applied to text elements, but it is most useful with replaced elements such as images or divisions.

The width is to be enforced by scaling the image if necessary. When scaling, the aspect ratio of the image is preserved if the "height" property is "auto".


img.width {
width: 100px;

<img class="width" src="images/image.gif" alt="" />

If the "width" and "height" of a replaced element are both "auto", these properties will be set to the intrinsic dimensions of the element.

Negative values are not allowed.