W3C home > Mailing lists > Public > www-validator@w3.org > February 2011

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

From: David Dorward <david@dorward.me.uk>
Date: Sun, 6 Feb 2011 23:23:59 +0000
Cc: www-validator@w3.org
Message-Id: <7E01EBDD-A428-4EC6-8482-D4FC4B15088A@dorward.me.uk>
To: Jan Bassez <janbassez@gmail.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:45 GMT