Tumblr 73444091
.
Regarding
class
. The comment that ‘Class attributes are meant to store machine information according to the W3C specs’ is completely incorrect, and is a suggestion that comes up over and over again. So:The HTML4 spec says, in §7.5.2 on
id
andclass
attributes: “Theclass
attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes.”Below, it says that class may be used for stylesheet selectors, and ‘For general purpose processing by user agents.’
That ‘general purpose’ statement is wildly and regularly misinterpreted as allowing class to contain arbitrary data, even though that use contradicts the ‘belong to these classes’ specification. A data value is not a classification. Further clarifying this, under the spec for the
id
attribute in the same section, ‘general purpose processing’ is defined more fully:‘For general purpose processing by user agents (e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.).’
Thus,
class
is for classifying elements and for identifying fields (which is exactly what microformats does with it). Those things taken together, I don’t see how the spec can be read as permitting data itself to be valid within the class attribute.Even if you disagree with my assertion that the ‘machine form’ is content,
class
is still an invalid place to stick it.
Ben Ward
A snippet of a comment I posted on Bruce Lawson’s ‘Microformats, accessibility, HTML 5 (again)’. The suggest that we just munge everything into the class
attribute keeps coming up, so wanted my latest rebuke of that idea preserved for posterity; I’m sure I’ll need it again.
Via: brucelawson.co.uk.
Links
To share this entry, or reference it in commentary of your own, link to the following:
- Permalink: https://benward.uk/blog/tumblr-73444091
- Shortlink: https://bnwrd.me/1a8YX0
You can file issues or provide corrections: View Source on Github. Contributor credits.