3 ms·
Understanding the cascade, general experience with building many varied sites, and hard work
by ehutch79 5y ago
Understanding the cascade, general experience with building many varied sites, and hard work
- z3t4 5y agoAnd that more specific rules override the cascade. And once you feel comfortable - try avoid using classes. (never use id)
- tomcam 5y agoWait wut? Sounds intriguing but also terribly inefficient.
- z3t4 5y agoCss classes will complicate the css it can for example become hard to see what takes precedence when you mix classes and element. And it doesnt help that CSS is also has significant white space as in .foo.bar vs .foo .bar So by practicing withot classes you will find that classes are rarely needed and in turn all your CSS get more simple - as long as you understand specifically. And you will also start to appreciate semantic HTML, and hopefully replace some of the divs with the appropriate semantic element!
- tomcam 5y agoI couldn’t agree more, and the hilarious thing is that I have spent much of the last few months doing exactly this. I’m writing yet another static site generator so by definition it must use classless HTML as the output. I am greatly enjoying the challenge of preserving semantic information while also making the output attractive. Thanks for the clarification!
- xqyf 5y agoNot just more specific rules, ones that just come later in source order too (with an identical specificity). Oh, and more "important" rules too. "!important" overrides everything. Well, except more specific instances of !important, or instances of !important with the same specificity but later in source order. Specificity is easy, the amount of specificity a selector has is measured using four different values represented by four single digits in four columns. (Of course, a single ID will override a thousand nested class selectors.) And that's ignoring the origin of the rule (author, user, or user agent stylesheet). And of course transitions override all of this. Isn't CSS fun?