[whatwg] Built-in image sprite support in HTML5

On Fri, May 21, 2010 at 10:12 AM, David Weitzman <dweitzman at gmail.com> wrote:
> There are various approaches to using image sprites with HTML and CSS,
> but at the end of the day they are all essentially hacks. A solution
> that would be simpler than any existing approach would be to introduce
> new attributes for <img> to specify x and y offsets and clipping on
> images. With that you would get simpler markup for sprites and better
> accessibility.
>
> One downside of this approach is that with background image sprites
> you can have a CSS class that abstracts away the name of the sprite
> image. With <img> tags you would have to specify the URL and
> height/width individually on every sprited image.

Agreed on all points about the current spriting solutions being hacks.

This problem is already being addressed on multiple fronts, though
they are all still somewhat theoretical at the moment.

The Media Fragments WG has a draft spec out for, well, Media
Fragments, which let you specify which section of an image you want
right in the url.  The browser should then automatically cut it out
and serve just the sprite you want.

The CSSWG has a few proposals in a very rough state, detailed in the
CSS Images spec.

Finally, there have been proposals for removing the need to sprite
altogether, by allowing authors to send a bunch of resources packed
into a single compressed archive, and just addressing individual files
inside of it.

So, while none of these are exactly imminent, there is activity in
this sphere already occuring.

~TJ

Received on Friday, 21 May 2010 10:23:55 UTC