|
First of all, thanks for the article. It's interesting to imagine how some of these selectors will be used in the future.
Now, a question:
I should probably already know this, but I haven't found a solution yet:
CSS is very good at allowing us to define a style which applies to every instance of an element (i.e. "p {color: blue;}"), then define further styles which refine details of particular instances of the same element (i.e. "p.special {color: orange;}").
This is good when I know that all of the settings I want to apply are descended from each other in a hierarchy which parallels that of the DOM tree.
But I've often found myself in the situation of manually recreating style settings for elements that are not so hierarchically connected. Using span elements for example, 90% of my document's span elements can get away with a single "span {font-family: sans-serif;}" definition, but the other 10% need over a dozen different style settings, each of which needs to apply a serif font. As I understand it, I'd have to define each of those styles independently (to cover the other variations between them), but include in each one the exact same font-family definition: "span.class_n {font-family: serif; ...}".
Is there a shorthand for this which involves less repetition? I imagined there'd be some sort of templating mechanism, something like "define myseriffont {font-family: serif; font-size: 12; ...} span.class_1 {myseriffont; ...} span.class_2 {myseriffont; ...}", but it wasn't there to be found when I went looking. Did I look in the wrong places? Has this sort of thing been suggested before and rejected for a particular reason?
|