3 ms·
This is really bad advice. He's suggesting that we make our CSS selectors more complex while simplifying our HTML to make it more semantic. While semantic HTM
by peterhunt 13y ago
This is really bad advice.
He's suggesting that we make our CSS selectors more complex while simplifying our HTML to make it more semantic.
While semantic HTML is a nice idea, it's not worth doing at the expense of well, basically anything else. It doesn't affect search engine ranking and there are easier ways to support assistive technologies (ARIA).
Making your selectors more complex comes with a great cost. Suddenly changes that would normally be simple cause cascading changes throughout your stylesheet and document because CSS is not very modular and complex selectors tightly couple multiple rules to your document structure.
This isn't an opinion or a matter of style. It is a simple, fundamental fact of computer science: that increasing coupling tends to make maintainability harder due to the number of cascading changes since multiple components depend on one another. And advocating Heydon Pickering's technique tightly couples your selectors to your particular document structure. Worse, it does so implicitly -- if you at least use class selectors this coupling is explicit and easier to reason about.
If he instead advocated something like SMACSS you'd have much more maintainable code.
- idProQuo 13y agoI'm new to web development, so I haven't dealt with a truly hairy stylesheet yet (though I've had plenty of experience with overcoupled and hard to maintain code). Do you think tools like Sass can help alleviate some of these CSS problems? I've heard that some people who go crazy with Sass end up with a couple thousand selectors, yet the organization and logic helps them manage the complexity.
- peterhunt 13y agoVariables are certainly awesome, but it's easy to get stuck in a situation where you generate giant stylesheets. It also doesn't really solve the selector modularity problem :/