W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] Cascading Attribute Sheets

From: Pentasis <pentasis@lavabit.com>
Date: Sat, 1 Nov 2008 19:11:53 +0200
Message-ID: <EF905BC34B1849DE914CD1212B1C9AA3@Sanktum01>
In the "add type to mark element" discussion which I started, a side 
argument about ids and classes was brought up.
I conveyed my opinion that I think classes should only be used as style 
handles and not to convey extra semantic meaning.
The HTML4 spec states:

"The class attribute has several roles in HTML:

    * As a style sheet selector (when an author wishes to assign style 
information to a set of elements).
    * For general purpose processing by user agents."

The first role is clear, it is used for styles (not semantics) the second is 
a bit more muddy I think, but the important part there is: "processing BY 
user agents". User agents have no interest in semantics, so I fail to see 
here also why classes may be used to define semantic roles.
The fact that a class should be named "footnote" for example is only so you 
will not get in trouble (unlike when you use a name like "red" or "left"). 
But this only tells me (the author) that this element should be styled like 
a footnote and for the user agent that it should render it like a footnote. 
It should not tell me (or anything else) that it IS a footnote. This would 
lead inevitably to inflexibility.

Let me however put forth a -maybe silly- idea I have had for a long time. In 
seperating content from style it would seem logical to me that the next step 
would be to place most attributes (except id and a new role-attribute) also 
in an external file. Assignment of attributes and purpose can then also be 
done externally from the html-file leaving it only to contain pure content. 
(this would benefit SEO, machine readability, accessibility and 
maintainability).

The obvious benefits would be that one can maintain things externally like: 
links, images, accesskeys, list-numbering, hiding, etc. and if we would 
assign a common attribute to all elements called "edit" we could set that 
externally too (like "draft, deleted, approved, date, etc.).
but the biggest benefit (I think) is that we can set classnames externally. 
this way we do not have to touch the html-file to change styles, but simply 
change the properties in the external attribute sheet. The new role 
attribute would be completely semantic and classes are no longer indide the 
html so their naming can be more style-related. And changing a style would 
no longer mean changing the stylesheet, but changing the attributesheet. It 
would make CSS a little bit more modular (and flexible).

Well, let me have it ;-)

Bert 
Received on Saturday, 1 November 2008 10:11:53 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC