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

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

From: Matthew Raymond <mattraymond@earthlink.net>
Date: Fri, 06 Apr 2007 07:31:09 -0400
Message-ID: <46162F7D.6040205@earthlink.net>
To: Maciej Stachowiak <mjs@apple.com>
CC: Daniel Schattenkirchner <schattenkirchner.daniel@gmx.de>, public-html@w3.org

Maciej Stachowiak wrote:
> 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.

   There are really only two arguments I've heard that make |role|
better than predefined classes:

1) The |role| attribute would be specifically defined as being semantic.
I'm not sure of what real benefit this is, since |role| would have to be
able to handle unknown roles, and there's no way to guarantee that such
known roles are truly semantic.

2) The roles would be defined separately from traditional classes, so
you'd have a logical markup separation between styling classes and
semantic roles that prevents naming conflicts between the two. The
problem with this is that people can still style the |role| attribute,
and in fact they will do so rather than putting |class| attributes on
every element that has a |role| attribute. As a result, authors will
invent new roles that skirt the border of semantics and presentation,
and some will probably use roles for presentational purposes because of
their default presentation.

   Personally, if we're moving everything to XML, I don't see the point.
You can just use attributes and elements from a new namespace. The
|role| attribute just shift semantics to a lower structural priority
(from elements and attributes to attribute values).
Received on Friday, 6 April 2007 11:33:52 UTC

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