Skip to main content
HTML Validation

Bad value X for attribute “width” on element “img”: Expected a digit but saw “"” instead.

About This HTML Issue

A stray double quote ended up inside the width value of an <img>, usually because the opening quote is missing (width=200") or the quotes don't match (width='200"').

The width attribute takes a non-negative integer: digits only, with no quotes, units or spaces. Without an opening quote, the browser reads the value as unquoted, which runs until the next space or >, so the closing " becomes part of the value. The validator reports this case twice, once with this message and once as “"” in an unquoted attribute value. When the value opens with a single quote and closes with a double quote, it runs until the next single quote, and the " again lands inside it.

Browsers parse width leniently and read 200" as 200, so the image often looks fine. A value that starts with the quote, such as "200", fails to parse, and the browser ignores it. The image then gets no reserved space before it loads, and the content below it shifts once it arrives.

Templates and string-built HTML cause most of these, for example width=<%= width %>" with the opening quote left out. Put matching double quotes around the number.

Invalid example

<img src="photo.jpg" alt="A red car" width=200" height="150">
<img src="photo.jpg" alt="A red car" width='200"' height="150">

Valid example

<img src="photo.jpg" alt="A red car" width="200" height="150">

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
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries