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

Re: Use the role-attribute instead of predefined class names

From: Maciej Stachowiak <mjs@apple.com>
Date: Fri, 6 Apr 2007 03:28:34 -0700
Message-Id: <79DF3AF9-E302-4C74-8E42-0C0B98D136A1@apple.com>
Cc: public-html@w3.org
To: Daniel Schattenkirchner <schattenkirchner.daniel@gmx.de>

Hi Daniel,

On Apr 5, 2007, at 12:26 PM, Daniel Schattenkirchner wrote:

>
> Hello, the following issue was already raised a few times, however,  
> there was no "big discussion" about it yet.
>
> In my opinion the XHTML 2 role-attribute is far superior to the Web  
> Applications 1.0 predefined class names because the latter got  
> several disadvantages:
>
> I don't think they are what most here call backward compatible.  
> Predefined class names are limited to few elements. I'm using class  
> names like "copyright" already and, like many other authors, I'm  
> not only using it on p- and span-elements. It'd be confusing if  
> some elements with class name X got a different meanign than  
> special elements with class name X. Also It's unclear how elements  
> with class names that aren't allowed on that element should be  
> handled. Are they invalid or ignored. I think that part of the WA- 
> Spec is very imature. (Adding new class names could be very chaotic  
> very soon).
> The same problem is applying to class names that aren't yet  
> predefined, but may become so in the future.
>
> Redundancy is alo a point that comes to my mind. I personally would  
> use a div- or section-element with the class name "copyright" as a  
> parent for copyright-specific paragraphs and lists. I think that's  
> better that a series of p-elements wearing the class name "copyright".

I think this is arguably a bug in the definition of the "copyright"  
predefined class name. It should probably apply to more things, at  
least <div> and <section>. And likely <small> as well, since a  
copyright notice is likely to be the kind of fine print that <small>  
is intended for in HTML5. But I don't see how a predefined  
"copyright" role would help matters any, unless it was allowed to  
apply to more elements than the current predefined class.

> Frankly speaking, I think predefined class names are confusing and  
> make an authors life harder. You've got to now, class name X is  
> predefined and class name Y can only be used on element Z. Not very  
> intuitive IMHO.
>
> My idea would be to merge the role-attribut with the predefined  
> class names (e.g. role="copyright"). This is reflecting my way of  
> using that class name (grouping elements in a div-element with the  
> copyright-class). However, together with the role-attribute, an  
> element would be enhanced semantically, which can be used by search  
> enginges and similar user agents.
> Besides, I think this approach is more useful when working with CSS.

I don't see how <div role="copyright"> would be any better  
semantically or otherwise than <div role="copyright">. And the role  
attribute is harder to style with CSS than the class attribute -- you  
have to write div[role=copyright] instead of just div.copyright.  
Furthermore, many UAs optimize class selectors more than general  
attribute selectors so it might be less performant as well as being  
harder to write.

In conclusion, I do not think your message shows any advantage for  
having both role and class attributes over having just class, and  
illustrates some disadvantages.

Regards,
Maciej
Received on Friday, 6 April 2007 10:28:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:15:52 GMT