Category:CSS Properties


The width property specifies the width of the content area of an element. The width of an element does not include padding, borders, or margins. Width can be defined in percent of the containing block, pixels, cm, etc.


Width in pixels

Setting the width of a <p> element to 300 pixels.

p {
  width: 300px;

Width as a percentage

Set the width of an <img> element using a percent value.

img {
  width: 50%;


width: value;


  • The width property does not include padding, borders, or margins.
  • The default value of the width is auto: The element will automatically adjust its width to allow its content to be displayed correctly.

Additional Information

For more information, see http://www.w3schools.com/cssref/pr_dim_width.asp

Found a bug in the documentation? Let us know at documentation@code.org