3 ms·
Consider though that this approach, using classes as functions, violates the primary intent of CSS, separating presentation from markup. You've now gone back t
by gnaritas 17y ago
Consider though that this approach, using classes as functions, violates the primary intent of CSS, separating presentation from markup. You've now gone back to modifying your markup to change the presentation.
I build skinnable sites, where there are multiple different looks for identical markup. The approach above would fail horribly at doing this. Markup should be semantic, a div with a class header or footer is semantically identical to a header or footer tag.
Markup is also quite often tightly coupled to code and much much harder to change than CSS, so this approach fails there as well. Blueprint takes this approach, and I think it's just wrong, this is not how CSS should be used.
What would be really neat would be a syntax to be able to have CSS classes inherit from other CSS classes like mixins so that you could build that header style by mixing in several selectors. Then you could use the above approach without corrupting the markup with style information keeping the look isolated to the CSS file. I see SASS provides, that alone makes it worth looking into.
- chriseppstein 17y agoLessCSS also does this. However, LessCSS lacks the capability to do macro expansion which greatly limits its usefulness as framework implementation language.
- gnaritas 17y agoDude, thank you, less is exactly what I've been looking for. It uses existing syntax and adds exactly what is necessary, macros are not. This I can teach to my designers, macros would only confuse them as would a different syntax.