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>


   <style type="text/css">
     <!-- div.center { text-align: center; } -->
   <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 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:05:57 UTC