Why the style attribute shouldn't be abandoned

     There once was a master webdesigner who used the
     style attribute. A novice designer, seeking to
     imitate him, also began to use inline styles. When
     the novice asked the master to evaluate his HTML,
     the master criticized him for using inline styles,
     saying, ``What is appropriate for the master is not
     appropriate for the novice. You must understand the
     Tao of Web Design before going inline.''

              -- Paraphrased from The Tao of Programming.


Good evening you all,

created a list of reasons, why I think the @style should
not be removed.


1. Some use cases

First I think, no-one has really pointed out good
use-cases for using inline styles.

1.1. Tag clouds
      <http://www.flickr.com/photos/tags/>

1.2. Bar graphs
      <http://concepts.waetech.com/bargraph/>

1.2. Computer-generated HTML
      The best example is Google giving you the HTML
      version of .doc or .pdf document.


2. Everyone is using it.

Let's face it, we all use it more or less. I use it.
You use it. Even the most committed content and style
separator guru uses it sometimes.

I don't mean using it in a finished web page. I mean
any use of it - even in the process of making a page
or debugging it, which takes me to...


3. It's really useful for debugging

It's clearly THE easiest ways to style a single element.
Quick and dirty prototyping anyone?


4. @style relates to <style> as <style> relates to <link>

Let's consider <style> and <link rel="stylesheet">.

When I have a lot of documents with same visual design,
then having <style> element with same declarations in
each of those documents is ceartanly evil. I should use
<link> to point to the common styles in separate file.

So, is the <style> element evil and should be dropped?

No, because when I have styles, that are specific to
just one document, then there is no big reason to create
extra CSS file for those styles.

Similarly with @style and <style>. If you have just
one element in one document, that you want to style in
a specific and unique way, then there is no logical reason
to make up new #id or .class.


4.1. Note, that removing @style would mean inconsistencies
      with current CSS spec.


5. What about JavaScript style property?

Even when we remove @style, the JavaScript style property
will still have to remain. And it clearly should, because
how else could you animate elements and do other dynamic
stuff like that?

But having no @style while having element.style looks
really inconsistent.


6. What about <script> and @onclick, @onmouseover, etc?

If we are going to drop @style, then we should be consistent
and also drop all the scripting related attributes too.




But what about PROs of dropping @style?

The only reason seems to be, that using @style is
mostly bad practice and having it available, encourages
all those bad practices.

But even if we remove the @style from the spec, it will
still be available for authors. Only those authors who
read the spec or use validator, will notice the change.
But aren't those the authors who would abandon those
bad practices anyway?


--
Rene Saarsoo

Received on Friday, 29 June 2007 22:46:25 UTC