floats
Hey, I was wondering if using float is useful in modern day css, I see mixed opinions on it showing that you shouldn’t use it or it’s right to use it for certain things, if that’s the case what sort of things should you use it for? Thank you in advance for any insight!
8 Replies
depends on the browsers you support. if you only support anything that supports grid, just use flex or grid (depending on the situation)
Use floats for what they were made for not for layout.
Grid is supported far back as IE so 🤷♂️
can always just use browsersync/postcss(autoprefix) too and not worry about the prefixes if you really wanted.
but #dIExplorer
that's a good use for floats
but for layouting of non-document-like stuff (stuff like menus), then use grid or float
Definitely do not use them as an alternative for flex or grid. Use floats for the one thing that neither of them can do well or may not be able to do at all. Floats can be used to get text to flow around images and arbitrary shapes. This is not only for rectangular shapes. You can use shape-outside with floats, and it won't work with anything else besides floats.
yeah, and even then, it's super super easy to break everything with those floats
As b1 showed, it's perfectly fine—and expected!—to use floats for what they're designed for: small elements to one side of the parent element allowing text and inline elements to wrap around it.
There is absolutely zero reason to use it for anything else, especially layout purposes. We have flexbox and grid. Both of which are supported in IE and any other browser you'd possibly need to support.
Don't layout with float. Just don't.
Ah this helps quite a lot, I really appreciate the in depth explanations from all of you!