# CSS: “width”: X is not a “width” value.

> Canonical HTML version: https://rocketvalidator.com/html-validation/css-width-x-is-not-a-width-value
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The CSS `width` property contains an invalid value.

The `width` property accepts specific types of values: lengths (like `100px`, `10em`, `5rem`), percentages (`50%`), viewport units (`100vw`), the keyword `auto`, and sizing keywords like `max-content`, `min-content`, or `fit-content`. The validator rejects anything that doesn't match these formats.

Common mistakes that trigger this error:

- Missing a unit: `width: 100` instead of `width: 100px`. Plain numbers (other than `0`) are not valid CSS lengths.
- Using an invalid unit or typo: `width: 100 px` (with a space), `width: 100ppx`.
- Passing a non-length value: `width: red`, `width: bold`, `width: none`. The keyword `none` works for `max-width` but not for `width`.
- Including extra characters: `width: 100px;50px` or `width: 100px !importnt`.

## Invalid example

```html
<div style="width: 600">
  <p>This box has no unit on its width value.</p>
</div>
```

The value `600` is not valid because it lacks a CSS unit.

## Fixed example

```html
<div style="width: 600px">
  <p>This box now has a valid width.</p>
</div>
```

Adding `px` (or another appropriate unit like `em`, `%`, `rem`, `vw`) makes the value valid. If the intent is to let the element size itself naturally, use `width: auto` instead.
