11 Vote

HTML Validation "img attribute width/height has invalid value"

Question by Guest | 2014-06-03 at 23:55

For the following HTML code:

<img src="img.jpg" alt="img" width="100px" height="100px">

I get these two errors in my HTML Validator:

Warning: <img> attribute "width" has invalid value "100px"
Warning: <img> attribute "height" has invalid value "100px" 

Can someone explain to me why this causes an error and how to get rid of this error message?

ReplyPositiveNegative
1Best Answer1 Vote

The declaration of "px" is not necessary with the attributes "width" and "height", because the values stated here are "px" by default. So, just write "100" instead of "100px":

<img src="img.jpg" alt="img" width="100" height="100">

This should fix the HTML Validator "errors".
2014-06-04 at 01:29

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.