Scripsit
Join Bytes!:
Quote:
The LaTeX macro I call "\display". Is there any reason I
shouldn't call the CSS "jukkaspecial" class by the name
"display", so that I'll remember what it does?
|
Generally, class names should reflect the meaning of elements. For
example, if the fragment is a mathematical formula, class="formula"
would be suitable.
In LaTeX, the approach is different in principle: you have formatting
commands (TeX primitives), and you define macros in terms of them. In
practice, it is rather the other way around: LaTeX macros often have
meaningful, semantically suggestive names, whereas HTML class names are
often macro-like.
In both approaches, semantically meaningful names are usually better
than purely presentation-oriented. They make the code easier to
understand (e.g., a few years later when you need to read it) and easier
to modify. Moreover, you may later wish to change the presentation
completely (e.g., for a different presentation medium);
presentation-oriented names would look rather silly after that!
This leaves the problem that you might wish to use the same rendering
for semantically different things, like formulas and news extracts. But
in CSS, this is easily managed. You could use class="formula" and
class="news" in HTML and a rule like
..formula, .news { ... }
in CSS. You can then later easily differentiate the renderings if you
like, e.g. by adding rules that apply to just one of those classes.
Quote:
My concern
is that "display" is also meaningful in CSS.
|
That's not a problem. There are no reserved names for classes, i.e.
anything that syntactically matches the pattern of class names can be
used, with no keywords extracted from the available name space. (The
so-called HTML 5 activity tries to change this, but this is just one of
its fundamental flaws.)
In CSS, you use a class name prefixed with a period ".", so ".display"
cannot possibly be mistaken for the property name "display" by a CSS
parser. Moreover, property names appear in CSS in certain contexts only
(inside curly braces "{...}" or in a style="..." attribute, where class
names cannot appear), and even this would be sufficient.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/