W3C home > Mailing lists > Public > public-html@w3.org > June 2007

Re: Why the style attribute shouldn't be abandoned

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Sat, 30 Jun 2007 01:55:07 -0400
Message-ID: <6b9c91b20706292255o47087e4dg4bdbba7a4ac6cada@mail.gmail.com>
To: public-html@w3.org

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

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:38:46 UTC