width

Sets the width of an element. It can be defined in absolute units like pixels or relative units like percentages.

It is documented as part of the CSS Box Sizing specification.

/* Usage Example */
.container {
  width: 100%;
  max-width: 1200px;
  /* responsive width was a max limit */
}

/* Syntax */
width: auto;
width: length-percentage;
width: min-content;
width: max-content;
width: fit-content;
width: calc-size;
width: anchor-size;

/* Global values */
width: inherit;
width: initial;
width: revert;
width: revert-layer;
width: unset;
Widely available Since 2015 96% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.

1+
1+
1+
12+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC