Henri Sivonen wrote:
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.

Technically yes, without a profile, they only have author-defined semantics which are unknown to anyone else, and I wouldn't expect a typical UA to be able to do anything with them. So, you could write <code class="red"> and define that to mean a snippet of HTML markup and style it appropriately (not necessarily red), but that wouldn't be very clear to anyone else, nor easy to remember. At least something like <code class="html"> is easy for yourself and others to work with.

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.

With meaningful class names, there doesn't necessarily have to be a spec defining them to be useful to anyone else. There's nothing stopping anyone looking at your source code and writing a user style sheet or user JS that works with your code. Without meaningful class names, doing that may be harder for the user.

As far as the UA goes, the "semantic" class names could be translated into Finnish or into Elvish or be replaced with unique random strings.

Indeed they could, and they would have exactly the same formally defined semantics as an english class name: none. The usefulness of a class name to others, though, is limited to those that understand or can roughly determine its semantics.

So in the end, home-grown class names are just style hooks when observed
outside the private universe of the author.

Also useful for scripting hooks.

--
Lachlan Hunt
http://lachy.id.au/


Reply via email to