3 ms·
Using float for layout isn't a great idea, but sometimes you have to. CSS Lint simply checks to see if you've used float more than 10 times, and if so, displays
by kenjackson 15y ago
Using float for layout isn't a great idea, but sometimes you have to. 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.
Why is using floats bad, and what are the abstractions one would use in place of floats? Tables? Or grids?
- huckfinnaafb 15y agoAFAIK all grid systems use float, maybe the suggestion is that you shouldn't be floating things constantly and instead use a grid system.
- nirvdrum 15y agoWouldn't that constrain you to fixed-width layouts then? Or are there grid systems for fluid layouts these days?
- huckfinnaafb 15y agoFloat has no say on the matter with regards to width. I use an extremely simple 14 line grid system that uses % widths, is nestable, and works in every browser I test it against. Not surprisingly this "system" (this word really makes it sound more than it is) can be found on one of the CSS Lint creator's Github: https://github.com/stubbornella/oocss/blob/master/core/grid/grids.css https://github.com/stubbornella/oocss/blob/master/core/grid/... While simple, it's definitely way more elegant than some of the grid systems I've seen built, such as the popular 960 fluid grid layout that ultimately generated nearly 800 lines of CSS for 5 columns. It also goes hand in hand with the core principles of OOCSS, which essentially states to extend classes and use multiple classes per element.
- nirvdrum 15y agoSorry, I should have clarified in stating fluid width layouts. I'm a much bigger fan of pages that specify the width as a percentage. Or that at least use max-width/min-width so I can expand the pages as needed. Every grid system I've encountered fixes the width at 960px or 980px. I've found floats are the best, but by no means, only way to achieve a fluid layout with a variable width.
- telemachos 15y agoA sub-question, if you don't mind my piggy-backing: Don't most grids rely on floats anyhow?
- pygy_ 15y agoI don't know either. I've posted a bug report demanding a clarification of the documentation on that point. https://github.com/stubbornella/csslint/issues/26 https://github.com/stubbornella/csslint/issues/26
- mark_story 15y agoDemanding justification for things a tool you got for free, is a bit ungrateful. Why not 'request' or 'ask', you might get a better answer. Demanding things from open source is a pointless venture.
- tiddchristopher 15y agoThe person you replied to might not be a native English speaker. Demand shares a common ancestry with the verb "to ask" in some languages. Take French's "demander" and you might see why someone could use "demand" in a way that sounds confrontational in English but quite normal in another language.
- jarek-foksa 15y agoFloats were originally intended to be used for floating images inside text blocks, not for layout purposes. The usage of floats all over the place is no longer justified since all major browsers support now inline-blocks and CSS tables.