4 ms·
Don't worry... CSS Lint is just anal. Your usage of those is fine in my book. I do the same stuff and I've been doing front-end development for something like
by bherms 15y ago
Don't worry... CSS Lint is just anal. Your usage of those is fine in my book. I do the same stuff and I've been doing front-end development for something like 7 years now.
- telemachos 15y agoFair enough and thanks for saying so. I suppose I just wondered what (if any) explanation there was for these particular preferences. That is, I understand that a linter (by definition) might be very picky and strict, but usually there's some basis for the rules. In the case of the two rules I asked about, I just don't see the rationale.
- bherms 15y agoYeah, the id thing is just bs. That's the point of id's, to be used for non-repeating tags in the html. While you could try to generalize and find all instances where id's shared similar properties, then extract those and apply them to classes, then add those classes to the elements, that just seems like a ridiculous approach to achieve reusability. In addition, if you move that direction, you start to deal with class bloat, which is no better than just adding inline styles (ie div class="red centered absolute fullwidth", etc)
- jacobr 15y agoExcept that would be declaring styles, and not content, in the markup which would not be something Nicole Sullivan would approve of. It would rather be div class="post" and class="post featured" or something like that.
- bherms 15y agoIn practice you wouldn't actually create just a red class or a centered class... I just meant to demonstrate that as you get more and more granular in the shared attributes of a module you can start getting css bloat... ie: you may have a lot of uses of color:red + position:absolute + top:0, which is then reduced to class = module1, and another set of reused rules reduced to module2, etc... It depends on how complex your css is really, but it's something to consider as you start to apply the rules more and more and make your css completely DRY.
- billybob 15y agoOf course, the absolute extreme of reusable classes would be if each class applied exactly one CSS rule. Then you could mix and match them in any possible way, at the cost of having 18 classes per element. But no one would do that. You don't need every possible combination because you want some consistent styles throughout your site. In Nicole's examples, she's getting pretty sophisticated effects, and I don't see her applying more than 3 classes to any element. (http://oocss.org/module.html http://oocss.org/module.html)
- billybob 15y ago"the id thing is just bs." By no means am I a CSS expert, but I'd hesitate to call someone's ideas "bs" if that person has the kind of experience Sullivan has. I may not like all of Douglas Crockford's suggestions in JSLint, but you know what? He's way more experienced with JS than I am, and doing what JSLint says has saved me pain on more than one occasion.
- Isofarro 15y agoNicole Sullivan has nowhere near the experience in CSS as Douglas Crockford has with JavaScript. Compare their writings and their talks on their specialist subject matter. Also compare what their peer say about them. For Crockford the negatives are his opinions as to what constitutes good JavaScript, but not against his knowledge and experience. Peer review is also an essential component. Crockford's contentious points are his opinions as to what constitutes JavaScript best practice, but his underlying knowledge and understanding is rock solid. I've found Nicole's understanding and knowledge of CSS falls short of the standard necessary to advocate CSS best practice with tools such as this. So she's failing at working with the strengths of CSS. Pick your role models carefully, and please, don't follow blindly.
- billybob 15y agoNeither Crockford nor Sullivan is a role model for me, and I'm not following blindly. I'm merely observing that Sullivan successfully refactored the CSS on Facebook and got them onto a better development path. That's pretty hard. I'm not going to blindly do whatever she says, but if someone wants to call her ideas "BS" and I don't know who that person is, I'm more likely to discard their opinion than hers. If that person is Eric Meyer, well OK then. You say her "understanding and knowledge of CSS falls short." Can you point to facts she gets wrong (not just opinions you don't share)?
- jacobr 15y agoNicole Sullivan, one of the creators of CSS Lint, is a proponent of what she calls Object-oriented CSS. It mean you define "objects" or "modules" that you reuse. The concept is not necessarily new, but she popularized it. You could for instance define some shared "widget" styles, and then some custom additional styles for a search widget and other additional styles for a filter widget. That way you only have to define the shared styles once, resulting in less CSS (DRY), easier maintenance and more consistency. She helped reduce the CSS of many Facebook pages massively using this technique. Read more at http://oocss.org http://oocss.org Also, just because you only have an element once at a page right now, you're not necessarily sure it will stay that way. Especially if the HTML code is in some shared template file that you use across your site.
- rimantas 15y agoAnd I recommend SCSS (http://sass-lang.com/ http://sass-lang.com/ instead. It solves many problems you can come across when dealing with CSS and in much more elegant way. E.g. rules reuse in SCSS can be done with @extend: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#extend http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#ex... That way instead of adding classes to your HTML you just group selectors in your CSS appropriately. Seriously, if you do CSS and did not try SCSS do it now.