Predefined classnames v/s roles (was: RE:Getting beyond the ping pong match)

To sum this all up, there are currently three solutions
for this problem:

Adding new attribute "role"

   + Totally new element, no conflicts with existing content.

   - The only difference with existing class attribute is,
     that it has semantics.

   - Not as easy to select with CSS:
     E.copyright  v/s  E[role~="copyright"]

Extending class attribute with predefined classnames

   + Many pages already use those classnames appropriately,
     so those pages would be automatically semantically enriched.

     The following table summarizes the use of different the
     proposed classnames on the existing pages according to
     my little survey [1]. The percentage is the percentage
     of pages using CSS.

     | classname | pages | percentage |
     | copyright | 23473 |     4.8114 |
     | error     | 15320 |     3.1402 |
     | search    | 10755 |     2.2045 |
     | note      |  3839 |     0.7869 |
     | warning   |  1893 |     0.3880 |
     | example   |   439 |     0.0900 |
     | issue     |   180 |     0.0369 |

   + Easy to select with CSS.

   - Some existing pages use those classnames in some other
     meaningful or even in a meaningless way.

     For example, an author might have specified a particular
     style for the copyright class, but then discovers, that
     he needs to style some other section of a pages the same way,
     and simply assigns the same classname to it. Of course,
     not a good practice, but the author knows, that classnames
     add absolutely no meaning to the page.

     It should of course be investigated, how often the particular
     classname is misused in WHATWG specification sense.
     Which is a daunting task, as it can't be done by machine.

   - Authors must watch out not to use predefined classnames
     in wrong contexts.

Extending class attribute with predefined classnames,
but prefix the classnames with something like

   + No conflicts with existing content.

   + Easy to select with CSS.

   - A bit strange syntax. Less easily readable.
     Not really a clean and sound solution.

   - Not really different from adding the "role" attribute,
     except the CSS selector problem.

When we leave aside the CSS selector issue, then the last
solution drops off.

Introducing the role attribute is clearly a safer way to go.
It ceartanly follows the don't-break-the-web-principle.

It is of course appealing to make pages, that already use
some classnames, automatically be more semantic. But what
about the future? From that moment on, we have to live with
those predefined classnames. What if at the next version of
HTML we discover the need for even more predefined classnames?
Who would like to live with the burden of remembering 10, 20,
50 or even 100 predefined classnames?

In my opinion, having predefined classnames is not future-proof
solution for this problem.


Rene Saarsoo

Received on Saturday, 5 May 2007 11:32:15 UTC