Re: About dropping the style attribute

On 6/26/07, James Craig <> wrote:
> Jens Meiert wrote:
> >> I've realized now that the current spec drops the style attribute for
> >> all elements except for the <font>, but I can't understand the
> >> reasoning behind those decisions.
> >
> > And neither do I, and according to my experience as well as the
> > discussion on that subject there are several cases why we need to
> > keep the "style" attribute.
> Some of the common JavaScript libraries use this for performance and
> consistency reasons, too. Prototype, for example, uses the [style] to
> toggle style values for a couple reasons. 1) So it doesn't have to
> override !important styles, and 2) because when checking the
> displayed state, performance of getAttribute is much faster than
> getComputedStyle.
> James

i still must insist that dropping the attribute form the HTML side
doesn't mean we won't have it on the javascript side as a property of

as for (1), !important is evil and only used on heavy spaghettized CSS
files. and to any extent, to override an !important rule the *only*
correct way to do it is using another !important rule with greater
level of specificity.
Having some of your rules set in the CSS with !important and then
overriding them on the HTML doesn't solve your problems more than it
creates them. (specially if team-working where someone else will
pick-up the project and be clueless that you sneaked some style
attributes into the HTML)

as for (2), that solely depends on browser implementation, the same
way as innerHTML is faster than manual DOM node creation when it
should be the other way around (innerHTML must be parsed and sanitized
before rendering, manual creation is assumed to be correct to the
If both getAttribute and getComputedStyle are supposed to retrieve the
same information, then it's a task for browser developers to provide
the exact (or approximate) same performance on both calls.

Received on Tuesday, 26 June 2007 19:22:31 UTC