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

David,

Based on the description that you have quoted, the validator is right.
However, the lack of a percentage specification would be a great
handicap for authors.

Sometimes, it is necessary to completely fill a <div> with the
contents referenced by an <iframe>.  In this case using width="100%"
is the perfect solution.  Otherwise, the rendering looks chopped off
when the browser display area shrinks or stretches beyond the number
of pixels specified in the iframe.  Specifying a fixed number of
pixels also results in more frequent display of multiple vertical
scroll bars: one for the iframe, and another one for the container web
page.

I have coded the following web page as an example of an <iframe> with
width="100%".  The iframe adjusts as the size of the browser window is
adjusted.  This would not be possible by coding a specific number of
pixels.

http://www.scientificpsychic.com/health/healthfr0.html

By the way, the w3schools.com site lists percentage values under size
and width for iframes, and I am glad that the major browsers support
them.
http://www.w3schools.com/html5/tag_iframe.asp

As a side note, I would like to note that I have been forced to code
frameborder="0" on  iframes even though frameborder is obsolete
because IE does not recognize style="border:0;" in the iframe and the
"seamless" attribute is not implemented in any browser yet.

Antonio Zamora
http://www.scientificpsychic.com/

===
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 Saturday, 3 September 2011 04:46:10 UTC