When people talk about microformats, they often have the same bit of confusion about the
class attribute; it is often referred to as a “css class.”
I’m not criticizing anyone here, I just want to point out that there’s some confusing regarding the
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.
There’s a couple of points I’d like to highlight here:
First, notice that classes are multivalued, meaning that elements can have one or more, space-sepearted values.
Next, notice that class values are not just for styling. While this is certainly the most common and well-known use for class values, they are open “for general purpose processing by user agents,” which could easily include non-intrusive scipting and semantics. In fact, classes actually work best when treated as a mechanism for applying semantics, rather than just hooks for styling (see Tantek’s Class for Meaning, not for show).