[whatwg] Use cases for style= on arbitrary elements

Matthew Paul Thomas mpt at myrealbox.com
Sun Jan 21 11:40:07 PST 2007


I've just encountered a couple of use cases for the style= attribute on 
arbitrary elements, rather than just <font>. (Sorry this isn't part of 
the relevant thread, as I haven't kept it.)

We have a set of things, stored in a database and listed on a Web page, 
where we want to indicate their age by making the older ones "fade 
away". This would be done by computing a shade of grey, and putting it 
in a style= attribute for the <li> element. Pre-computing the values 
for all of them in a <style> element, then attaching the appropriate 
class= to each <li>, would not only be a lot of extra work, it would 
also involve either iterating through the list twice (once to calculate 
the sizes and construct the classes, once to actually render the list) 
or caching the items from the database, which would be a lot of extra 
work. We could add a <font> element around every list item, but that 
shouldn't be necessary.

A more common example is tag clouds, where a computed size is given in 
the style= attribute of an <a> element. In that case, there is the same 
objection to using classes. And there is a more practical objection to 
using <font>: in a cloud that showed hundreds of tags, an extra element 
for each of them would add substantially to the size of the page.

Cheers
-- 
Matthew Paul Thomas
http://mpt.net.nz/




More information about the whatwg mailing list