Henri Sivonen wrote:
Lachlan Hunt wrote:
He meant that the class names used should not be used to describe the
presentation, but rather describe the semantics. It is, however, ok to
use stylesheets to add styles based on the classes.
eg. These are bad practice:
<span class="bold red-border">
<p class="blue-text">
<div class="big bold">
These are better:
<strong class="warning">
<p class="summary">
<h1 class="title"> (or simply <h1>)
Of course, the UA does not care about "semantic" class names. In both
cases, the UA only sees opaque strings that can be tested for equality
with strings present in CSS selectors.
The class names in the latter case may be "semantic" in the private
universe of the author, but they do not communicate semantics to
software developed by someone else without a prior agreement (possibly
in the form of a third-party spec) on the meaning of the class names.
While it's true that the UA does not understand the author's semantics,
the second example is better coding because it separates content and
style. To draw an analogy, if/else/while are all transformed to goto
statement during compilation but writing if/else/while is nonetheless
better C programming practice than writing gotos.
~fantasai