The width property specifies the width of the content area of an element. The content area is inside the padding, border, and margin of the element.

  • Initial valueauto
  • Applies toAll elements except non-replaced inline elements, table rows, and row groups
  • InheritedNo
  • MediaVisual
  • Computed valuePercentage or absolute length
  • AnimatableYes
  • CSS VersionCSS1, CSS2, CSS3
  • JavaScript
Formal syntax: <length> | <percentage> | auto

width: 400px;        /* Length value */
width: 80%;          /* Percentage value */
width: auto;
  • <length>Specifies the width of the content area using a length unit.
  • <percentage>Integer, followed by a %. The value is a percentage of the width of the parent object, whether or not it is specified explicitly. Negative values are not allowed.
  • autoThe width depends on the values of other properties. See the sections below.
  • border-boxIf border-box is used, the length or percentage defined will be applied to the element's border box.
  • content-boxIf content-box is used, the length or percentage defined will be applied to the element's content-box.
  • autoIf auto is set for the elements width, the browser will determine the width for the element.
  • max-contentThe intrinsic preferred width
  • min-contentThe intrinsic minimum width
  • availableThe containing block width minus horizontal margin, border, and padding
  • fit-contentThis will be either the large of the minimum width or the smaller of the preferred width and the available width
.class {
   width: 150px;

Click the button below to experiment with this property.

Give it a Try!


Last updated on 23rd March 2014 By Rene Spronk

View All CSS Properties

Errors? Please help to keep this list up to date, If you find any errors, please contact us, so that we can get them fixed.