Re: Why the style attribute shouldn't be abandoned

Thinking of reasons I've used the style attribute before, I can only
come up with a few.

1. Laziness when testing.
2. Catering to Netscape 4.8.
3. Providing a default style so element.style.display is defined. (for
toggling purposes)

#3 is the only one that might count here. However, a style sheet,
getComputedStyle or currentStyle, and general scripting could solve
that.

However, in this case, I might do:

div.x {display: none;}
<div class="x" style="display: none;">

, and justify that by saying:

1. When the stylesheet(s) is present, the style attribute is just a
description of some or all of the styles that the stylesheet(s) will
apply to the element.

2. When the stylesheet(s) is not present, the style attribute provides
the styles that should have been applied by the stylesheet(s) if it
was there (like fallback).

3. As a bonus, the .style properties for the corresponding styles in
the style attribute will have a default value.

I don't know if I'd buy that though. :)

-- 
Michael

Received on Saturday, 30 June 2007 05:55:10 UTC