W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2010

[whatwg] img as a layout tool to describe the displayed region of a CSS background-image

From: Steve Dennis <admin@subcide.com>
Date: Wed, 28 Apr 2010 21:04:09 +0100
Message-ID: <F7FD2087-6A1C-45AD-A0E3-4A03B1065049@subcide.com>
On 28/04/2010, at 7:43 PM, Tab Atkins Jr. wrote:

> On Wed, Apr 28, 2010 at 4:31 AM, Ingo Chao <i4chao at googlemail.com> wrote:
>> http://dev.w3.org/html5/spec/Overview.html#the-img-element
>> "The img must not be used as a layout tool.

I think this may be a little vague/broad.  I understand the intention, but say for example I have a logo image in the top left of my header, and my header doesn't have a static height set (in case something in the header needs it to grow or shrink for instance), then the height of the logo image is dictating the height of its parent, and this would seem to me, to be using an img as a layout tool, in a sense.

>> In particular, img
>> elements should not be used to display transparent images, as they
>> rarely convey meaning and rarely add anything useful to the document."
>> 
>> An img with a given transparent image for src cuts an area of a sprite.
>> ( = img as a layout tool to describe the displayed region of a CSS
>> background-image.)
>> 
>> Is this usage of the img element considered invalid (non-conforming)?

Sprites for icons, while widely used and considered fairly good practice, still seem pretty hack-ish to me.  Icons can (arguably) help convey meaning in a document, and changing a background position to change that meaning doesn't seem like the best way of achieving this.  I am of course thinking like 10 years into the future here, as sprites are perfectly fine for lots of uses today, but as concurrent connections become less of a problem, I think lots of us will look back on sprites the same way we see spacer.gifs, which were a necessary evil at the time.

- Steve Dennis

> 
> Yes, this is using the <img> as a layout tool.  Specifically, you're
> using the <img> to avoid specifying "width" and "height" in CSS, and
> to enable further layout hacks with sprites using
> background-positioning.
> 
> ~TJ
Received on Wednesday, 28 April 2010 13:04:09 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:22 UTC