Skip to main content
HTML Validation

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

About This HTML Issue

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

<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

<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.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries