W3C home > Mailing lists > Public > www-style@w3.org > August 2009

Re: Image sprites use cases

From: Alex Kaminski <activewidgets@gmail.com>
Date: Sun, 30 Aug 2009 20:38:04 +0200
Message-ID: <6328fb9a0908301138i359904dbuceb2487e73c5774f@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style@w3.org
On Sun, Aug 30, 2009 at 12:07 AM, Tab Atkins Jr.<jackalmage@gmail.com> wrote:
> Using the new sprite practice from the MFWG would be 12 rules for just
> checkbox, and 24 when you add radio - one per type/state/interaction
> combo.  This is more verbose, but it's necessary for a general
> solution.

Unfortunately what we have in reality is more complex than my initial example.
We also provide small/large variants plus classic/xp/vista/osx look. That would
make 192 rules (instead of 23 using background-position-x/y +
Now if we want to add just one more variant (say small/medium/large)
we would be
forced to add another 96 rules (instead of 8).

This is even worse for a button control - we are using 9 fragments to
assemble the
button image (4 corners, 4 sides, center fill) instead of a single fragment for
the checkbox. So we easily start talking about hundreds of rules here - it
goes out of control very very fast.

> ...  I hope you agree that
> list-style-image-position-x is kinda ridiculous.  ^_^

Well, yes :-(   but writing 192 rules is also quite sad...

> So, unfortunately, we're kinda stuck.  We can't split out the
> properties everywhere we want to use sprites.  We can't use the
> cascade without splitting out those properties.  So we just plain
> can't do what you're asking in a general solution.

Maybe splitting the properties is not that bad? I agree that having
list-style-image-position-x is an overkill but maybe
background-image-region: x,y,w,h could be acceptable?

> However, there is hope.  Just keep doing what you're doing.  Use
> background-image and background-position when you can accept the
> limited use and restrictions.  It's easy, it's well-known, and it
> won't ever stop working.  And then, when you want to use sprites
> somewhere else, use the # to simple select a subregion of an image.

Yes, I understand that the current 'hacks' will continue to work, but we were
hoping for a less painful life sometime in the future :-) Ideally being able
to use multiple backgrounds on the single element together with background-size
and background-repeat properties and all coming from a single composite image.

> Slightly more verbose, but it works great.

I am afraid that without splitting the properties the current
proposals will bring
'exponential' verbosity - yes, it will works great in simple cases but
it may become
extremely verbose with a large number of sprites/image variants.

Alex Kaminski
Received on Sunday, 30 August 2009 18:38:44 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:28 UTC