Re: Image width specification in html5

David Swindlehurst <davidms@uwclub.net>, 2011-11-20 13:55 +0000:

> <div class="?"><img src="image.png" alt="ancient grey-haired awkward person"
> width="25%" /></div>
> 
> results in an error - the Validator expects an absolute number (of pixels!).
> Fixing image width like this prevents correct rendering of the page in any
> size of display different from the writer's original. Although there is a
> mass of insignificant discussion in the current Specification about the
> "alt" tag, there is no mention of image sizing at all, which seems to me to
> be far more important. Does the Spec need revising, or is the Validator
> wrong in expecting an absolute number?

The relevant part of the spec is this:

  http://dev.w3.org/html5/spec/the-map-element.html#attr-dim-width
  Author requirements: 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.

"25%" is not an integer, so the validator behavior conforms to the spec in
correctly reporting an error for it.

See also the last part of the "Changed Attributes" section of the "HTML5
differences from HTML4" document, which says:

  "The width and height attributes on img and other elements are no longer
  allowed to contain percentages."

  --Mike

-- 
Michael[tm] Smith
http://people.w3.org/mike/+

Received on Monday, 21 November 2011 08:10:51 UTC