5 ms·
There's opinionated, and there's badly-thought-out. From the article: = Don’t use too many floats = Arbitrary, and impossible to test for. All Lint is do
by damncabbage 15y ago
There's opinionated, and there's badly-thought-out. From the article:
= Don’t use too many floats =
Arbitrary, and impossible to test for. All Lint is
doing is counting how many times you declare "float"
in a stylesheet. It doesn’t matter that you may only
ever use one float on a given page.
I agree with Wilcox on this; between that, "Don't qualify headings" and "Don’t use IDs in selectors", I'm not crash-hot on using CSSLint for anything other than plain syntax checking.
- telemachos 15y ago>> using CSSLint for anything other than plain syntax checking. More straightforward to use the W3C's CSS validator for that: http://jigsaw.w3.org/css-validator/#validate_by_uri+with_options http://jigsaw.w3.org/css-validator/#validate_by_uri+with_opt...
- bobfunk 15y agoI don't think the "Don't use too many floats" is meant to say anything about performance, but about maintenance. I think the point is, that if you have to put "float" in lots of declaration, you're missing some abstractions in your css. Most likely a grid plus some classes for inline lists. Again, CSS Lint is very opinionated, and some of it opinions are contrary to various best practices (especially the fundamentalist approach to not let any classes in the HTML have anything to do with presentation). But from the perspective of these opinions based on how to write maintainable CSS and HTML for large sites, the rules makes a lot of sense.
- pornel 15y agoI don't think maintenance difficulties are related to number of float declarations. I could make layout a ticking time bomb just by using one shrink-wrapped floated column without clear. I could make mess of an entire site with just: .left {float:left} (which I've seen used in practice) And I can write perfectly maintainable code with lots of floats if I have them sized and cleared properly.
- voidfiles 15y agoHaving too many floats is the canary in the coal mine. It's there to help you have a sense of how well you are structuring your CSS.
- pbhjpbhj 15y agoIt gives a float warning. Seems reasonable to me. A warning doesn't mean you have to change anything it just means you might want to look at this. If you understand your code and know that the multiple floats are there on purpose then there's nothing more to do. Like someone else said this is a "perhaps you should be using a proper grid" warning.
- catshirt 15y agoI'll quote something from CSS lint I've quoted here before and probably will have to quote again; "CSS Lint simply checks to see if you've used float more than 10 times, and if so, displays a warning. Using this many floats usually means you need some sort of abstraction to achieve the layout.". Really, honestly, what does this even mean?
- huckfinnaafb 15y ago"CSS Lint simply checks to see if you've used float more than 10 times, and if so, displays a warning. Using this many floats usually means you need some sort of abstraction to achieve the layout." I suspect this means you should be using a grid system, either hand written or borrowed from somewhere that writes grid systems. Constantly using float everywhere is completely unnecessary for larger sites.
- catshirt 15y agosorry... grids float, no?
- huckfinnaafb 15y ago...yes, but they often only declare it once.
- voidfiles 15y agoI think the point is that if you are using floats in too many places you there are probably a whole host of other problems with your CSS. If you took the time to go over your CSS, and find where you are duplicating effort you might be able to reduce the number of CSS classes you are using by finding a common pattern. Thus abstracting your CSS.