Re: Image width specification in html5

Seen from an XML perspective: attributes contain meta information
about the element they're used on. So width and height should describe
the _actual_ width and height of the image file defined in the <img>
element's src attribut. That's markup. CSS is used for styling your
markup and thus you should use CSS' width and height properties to
define how big your image should be displayed in your document. That's
probably the reason the HTML width/height attributes are being ignored
when specifying a different size in CSS although width/height
attributes are "inline". By defining width=3D"75%" in your markup you



2011/11/21 T.J. Crowder <tj@crowdersoftware.com>:
> On 21 November 2011 11:59, Jukka K. Korpela <jukka.k.korpela@kolumbus.fi>
> wrote:
>>
>> 2011-11-21 13:03, T.J. Crowder wrote:
>>
>>> Separately: Do you have a use-case for using percentage values for
>>> `width` / `height` on `img` elements?
>>
>> The most obvious use case is perhaps showing an image as large as possible
>> within the available width, by setting width="100%".
>
> True. It runs afoul of the note[1] in the current draft that "The dimension
> attributes are not intended to be used to stretch the image."
> I should have been clear that I don't particularly advocate using percentage
> values on `width` and `height` (not that anyone's likely to ask me), as at
> least one who replied off-list thought. I was addressing the claim that
> inconsistency in implementation was a justification for removal, which
> appears not to be the case.
> It would be useful if someone actually involved in the decision pointed to
> the rationale, ideally by pointing to where it was discussed and agreed.
> The primary purpose, as I understand it, of `width` and `height` on `img`
> elements is that they are rendering hints, so the layout engine can set
> aside space for the image prior to downloading the image data (in fact, the
> HTML5 draft says[1] "User agent requirements: User agents are expected to
> use these attributes as hints for the rendering."). Percentages do that just
> as well as pixel values, implementations do it consistently, so it's unclear
> why removing percentage values is important.
> [1] http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width
> --
> T.J. Crowder
> Independent Software Engineer
> tj / crowder software / com
> www / crowder software / com
>

Received on Monday, 21 November 2011 17:53:51 UTC