# width property

The `width` property sets an element width. The property value is any size units or the key property `auto`, which allows the browser to independently calculate an element size (default behavior).

## Syntax

`selector { width: value; }`

## Example

Set the element width to `300px`:

`<div id="elem"></div>` `#elem { width: 300px; height: 100px; border: 1px solid black; }`

:

## Example

Let's make the element take up `70%` of its parent width (in our case this will be the browser window):

`<div id="elem"></div>` `#elem { width: 70%; height: 100px; border: 1px solid black; }`

:

## See also

- the `height` property
  that can be used to set an element height
- the `width` attribute
  that can be used to set an element width

← →
↑
en ru