Francisc
Francisc

Reputation: 80445

HTML5 validation of image tags

Am I not allowed to specify the unit for width and height on <img> tags in HTML5?

I am getting this error from the validator:

Bad value 122px for attribute width on element img: Expected a digit but saw p instead.

Upvotes: 9

Views: 32770

Answers (3)

Shehzad Ahmed
Shehzad Ahmed

Reputation: 51

just write 122 instead of 122p

Upvotes: 4

Zain
Zain

Reputation: 283

Move the percentage width from the html tag to the in-line style:

For example:

Change this line

<iframe width="100%" height="588" style="border:none; background:transparent; overflow:hidden;" />

to this:

<iframe height="588" style="border:none; background:transparent; overflow:hidden; width:100%;" />

then it will validate...

Upvotes: 7

George Cummins
George Cummins

Reputation: 28906

Drop the 'px' part. Use only non-negative integers.

Upvotes: 23

Related Questions