Re: Classes Considered Harmful

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 UTC