Why does the W3C validator show error messages for these IMG attributes?


I have an IMG tag in my HTML5 document that reads:

<img src="elements/background.png" alt="" width="100%" height="100%" />

When I run the document through the W3C validator (doctype is HTML5, encoding is UTF-8), it comes up with two error messages, one for the width attribute and one for the height attribute. Both say something to the effect of, "Expected a digit but saw % instead."

I checked on the W3C website, and the width and height attributes for the IMG tag both still support percentages in HTML5. What’s going on?


According to W3C:

[…] The attributes, if specified, must have values that are valid non-negative integers.

4.8.16 Dimension attributes

Change the values to integers or use CSS.

Answered By – vinga

Answer Checked By – Marie Seifert (AngularFixing Admin)

Leave a Reply

Your email address will not be published.