This is Richard Jp Leguen's TypePad Profile.
Join TypePad and start following Richard Jp Leguen's activity
Richard Jp Leguen
Recent Activity
While I understand the desire for inheritance from one CSS rule to the next, it doesn't fit with the paradigm for CSS; a class attribute or id attribute isn't like specifying an instance of a class. It would create ambiguity about how rules apply or inherit:
div#gloablNav .current {
color:blue;
}
div#currentNav .current {
color:red;
}
#main .intro a[href=/'] {
.current; /* which rule does this inherit from? */
}
Is the solution to this ambiguity to copy the entire CSS rule?
#main .intro a[href="./"] {
div#currentNav .current;
}
... but CSS rules aren't unique, and the author (or maintainer) have no way of knowing in which CSS file this rule would have been defined, or if it is at all. And if this rule and another 'collide' how do I determine precedence? Can we make CSS stricter and demand uniqueness of selectors across all CSS files? No, because in web dev Forgiveness is the Default. http://www.codinghorror.com/blog/2007/04/javascript-and-html-forgiveness-by-default.html
The reality is that CSS isn't meant exclusively for developers and so it shouldn't support programming paradigms like inheritance or recursion or namespaces which are overwhelmingly familiar to developers. That doesn't mean, however, there isn't some method to CSS's madness; I'd worked and studied in web dev for quite some time before I discovered there was some kind of math behind the precedence of CSS rules, and it was a revelation and an eye opener; http://www.w3.org/TR/CSS2/cascade.html#specificity
What's Wrong With CSS
We're currently in the midst of a CSS Zen Garden type excerise on our family of Q&A websites, which I affectionately refer to as "the Trilogy": Server Fault Super User Stack Overflow Meta Stack Overflow (In case you were wondering, yes, meta is the Star Wars Holiday Special.) These sites a...
Richard Jp Leguen is now following The Typepad Team
May 3, 2010
Subscribe to Richard Jp Leguen’s Recent Activity




