Re: 'px' or'%' given with values for width&heigth attributes gives validation error (html5)

On 6 Feb 2011, at 18:32, Jan Bassez wrote:

> <iframe name="info" src="owstone.html" seamless="seamless" width="100%" height="45px" style="overflow: hidden;"></iframe>
> 
> this gives an error in the validator for html 5 ->
> Bad value 100% for attribute width on element iframe: Expected a digit but saw % instead.
> Bad value 45px for attribute height on element iframe: Expected a digit but saw p instead.
> 
> Technically the px can be left away, but the % for sure not.

In HTML 4, the height and width attributes take a Length value: http://www.w3.org/TR/html4/types.html#type-length

Thus 100% is fine, but 45px is an error since it isn't a plain integer value. 

In HTML 5, however: 

http://www.w3.org/TR/html5/the-map-element.html#dom-dim-width

> The width and height attributes on img, iframe, embed, object, 
> video, and, when their type attribute is in the Image Button state, 
> input elements may be specified to give the dimensions of the visual
> content of the element (the width and height respectively, relative
> to the nominal direction of the output medium), in CSS pixels. The 
> attributes, if specified, must have values that are valid non-negative
> integers.

This removes the percentage option provided by HTML 4 (possibly an error on the part of the spec authors, since they tend not to remove things from HTML 4), but maintains the "Do not specify units" rule for pixel values.

In short, the validator is right and this is not a bug.

-- 
David Dorward
http://dorward.me.uk

Received on Sunday, 6 February 2011 23:24:35 UTC