W3C home > Mailing lists > Public > www-html@w3.org > August 2001

Re: Classes Considered Harmful

From: Sean B. Palmer <sean@mysterylights.com>
Date: Mon, 13 Aug 2001 18:40:25 +0100
Message-ID: <016101c12421$065f15a0$43dd93c3@z5n9x1>
To: "Kurt Cagle" <cagle@olywa.net>
Cc: <www-html@w3.org>
Kurt Cagle <cagle@olywa.net> wrote:-

> Classes by themselves were meant as a mechanism for
> adding presentation to HTML markup, [...]

Taking "were" to mean "are", that's wholly incorrect. Classes are a
means of labelling elements to indicate further semantics, e.g. by
classifying a set of elements into one group. Styling should then be
applied according to that; not as a direct consequence of it.

Of course, that's the theory of it. In practise, people just use them
as a substitution for presentational markup, which kind of undermines
the whole purpose of classes. For example, what really is the
difference between:-

   <div align="center">[...]</div>

and:-

   <style type="text/css">
     <!-- div.center { text-align: center; } -->
   </style>
   [...]
   <div class="center">[...]</div>

People should be asking themselves why they are centering an element
rather than just doing it. Write what you mean, rather than what you
want done with it. One of the problems that I have raised with classes
is that the theory and practice do not match because there is no way
to define the semantics of the new classes created.

--
Kindest Regards,
Sean B. Palmer
@prefix : <http://webns.net/roughterms/> .
:Sean :hasHomepage <http://purl.org/net/sbp/> .
Received on Monday, 13 August 2001 13:53:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:49 GMT