Good points, Bill. I've been thinking about these different approaches
myself.
> Both frameworks support this. Compass does with SASS mixins at the
> expense of server-side simplicity and minimal CSS code size since it
> requires a CSS preprocessor (SASS). OOCSS does it with vanilla CSS at
> the expense of semantic markup since it requires non-semantic classes
> on HTML elements.
That's the key. It's about where it makes more sense to make these
compromises. OOCSS leaves you with a lot more markup, period, not just
unsemantic markup. The philosophy avoids modules which means you gain
predictability for what <li> looks like, but you need to set its class
everywhere you need to style <li> differently, even though it might be
in its own module that you'd otherwise target as a descendant
selector.
It's not quite as bad as font tags, but it still means there's a
proliferation of style-dependent classes on every element. On the
other hand, this is how all desktop page layout software (for print)
operates: if you want to style an element, you select that element and
apply a style. It's very direct and concrete.
> There is nothing semantic about unit, size1of2 or lastUnit. This is a
> violation of (part of) Best Practice #2: "Use consistent semantic
> styles". It's consistent but it's not semantic.
> The crux of my original question about middle ground stems from Chris
> Eppsteins stated philosophy (apparent) of having an almost 1-1
> correspondence between HTML elements and CSS rules. I don't think that
> philosophy is inherent in SASS/Compass, it's just one (extreme) way of
> applying SASS/Compass.
I don't think that's necessarily a philosophy. If you're referring to
the video where Chris takes a chunk of markup, removes the content,
and then adds styles to the same structure, that's just a
demonstration of the syntactical similarity between Haml and Sass
which allows you to easily do that. It's a great starting point for
figuring out "what hooks do I have to style" but it's still up to you
the designer to realize that you'd end up over-specifying your
selectors and you still need to generalize & optimize from there...
> Imagine a hybrid: OOCSS implemented as SASS mixins in Compass. This
> would effectively eliminate Pitfall #1/Best Practice #9. The benefit
> would be stronger support for Best Practice #2.
Where are these numbers you're referring to? It seems I haven't read
the rulebook...
> At the same time I'd like to imagine that hybrid NOT promoting
> proliferation of selectors beyond what is necessary to make up for the
> loss of the non-semantic CSS classes. So we maintain Best Practice #6
> "Minimize selectors" but we do so in such a way that we sustain Best
> Practice #2. In short there are more selectors than we currently have
> w/ OOCSS but we still strive to minimize them. The "two main
> principles" of OOCSS remain intact (#1 separate structure and skin, #2
> separate container and content).
The key difference as I see it is OOCSS' rejection of modular
structure. While I like some of the ideas that OOCSS presents, I still
think there's a place for modules and reusing of elements for
different styles, if the modules are clearly defined.
The trouble with modules is nested content, (imagine sub-sub-modules)
where you'd need to override to cancel out the parent styles. This is
what Nicole's "lady who swallowed a fly" analogy is about, which I
think is a great one. The reality is that we're limiting ourselves to
a crippled CSS selector set due to IE6 and other older browsers when
we could be using direct child selectors to avoid these problems.
But, philosophically that means that you're connecting the structure
to the content, whether you intend to or not. (Maybe CSS needs to have
"private" attributes if we're seriously talking OO.)
> And in the end you still have a library of reusable parts. It's just
> that those parts are implemented as SASS mixins instead of CSS
> classes. So a large organization or large community still benefits
> from reuse. That's key.
I think the features of Sass/Compass are orthogonal and a superset of
OOCSS. You can still write your Sass with a flat structure, and use
mixins to avoid repeating common utility rulesets.
In the end it's (mostly) about how easy it is to maintain the content
and pages that your stylesheets apply to. I think I would find it
easier to apply a module class and leave the content to style itself
than to go around applying style classes to individual elements.
Also, it seems that OOCSS was born from performance optimization. If
the question were purely about CSS performance, then it makes sense
that the approach would not be optimal from other aspects. It makes
sense that you would need to add HTML selectors and flatten the CSS if
you have a super-complicated page that you need to speed up. But is
that how we want to have our HTML?
Andrew Vit