W3C home > Mailing lists > Public > www-style@w3.org > July 1999

meaning of the class attribute (was Re: <U> Deprecated)

From: John Whelan <whelan@itp.unibe.ch>
Date: Sat, 24 Jul 1999 08:42:58 -0400 (EDT)
Message-id: <199907241242.OAA21658@itp4.unibe.ch>
To: derhoermi@gmx.net, www-style@w3.org
Bjoern Hoehrmann replies to my post:

> | A <dfn class="underlined">programmer</dfn> is ...
> |
> | <em class="underlined">Don't mention the war!</em>
> |
> | with the stylesheet declaration
> |
> | .underlined {text-decoration: underline; font-style: normal}

> "underlined" is no good name for a class. As you said: use names for
> classes that carry the *meaning* of what you're trying to
> describe. If you later want you EM red, bold and italic instead of
> underlined, it would be very confusing, if the name of the class is
> 'underlined'.

Is this actually the case?  My impression was that the class attribute
was meant to be interpreted by user agents rather than readers, and
thus could equally well be "underlined", "definitionofperson", "a1",
"jabberwocky" or whatever.  According to the HTML 4.0 spec
<http://www.w3.org/TR/REC-html40>:

   The class attribute, on the other hand, assigns one or more class
   names to an element; the element may be said to belong to these
   classes. A class name may be shared by several element instances. 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.

It says nothing about giving classes meaningful names or user agents
passing the class names on to readers.  Of course, it helps to have
class names which are meaningful to the author or maintainer of the
page; in the example above, if you want *all* definitions to be
underlined, you would of course use

  A <dfn>programmer</dfn> is ...

with the stylesheet declaration

  dfn {text-decoration: underline; font-style: normal}

The situation I had in mind was one where some definitions are
supposed to be underlined and some marked up in other ways, and so
<dfn class="underlined">programmer</dfn> was a way of marking this as
one of the definitions that was in the former group.

> | Each of these examples would be better handled by using HTML tags
> | which carry the *meaning* of what you're trying to describe and then
> | using stylesheets to customize the appearance if you like:
> 
> Yes, and it is the same with Style Sheets, so

The difference is that the HTML tags have agreed-upon meanings laid
out in the W3C recommendations, while class names do not.

					John T. Whelan
					whelan@iname.com
					http://www.slack.net/~whelan/

      ------------------------------------------------
          only 34 days until the Swiss premiere of
         Star Wars Episode I: "The Phantom Menace"!
                Thank you for not spoiling.
Received on Monday, 26 July 1999 06:27:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:59 GMT