Browsing through some old articles and blog posts I had bookmarked but never got around to, one example required the float property. It got me thinking, I don’t think I’ve used that property for a new project over the past 10 years or so. I’m sure I’ve used it for something on a legacy project, but overall just a handful of times in 10 years.
Given the headaches the float property gave me over the early years of my career, I’m so much happier using flexbox and CSS grid.
When was the last time you used it? Is there still a place for floating in CSS?
Top comments (3)
For sure. If Float was a new property, devs would be quite excited of gaining the ability to wrap text around images and figures which is the thing that flex and grid can't do.
The issue with float was that it was shoe-horned into a use that it was never designed for, as a way of achieving grid layouts. Now we have the tools to do that properly, float can return to its original intended use.
That's definitely a use case I thought of while writing the post but I can't even remember the last time I saw this layout device used anywhere other than Wikipedia.
I searched through my website and there's only one page that contains
float
property.The website was rebuilt in 2017 with Pure CSS library.
This particular page was a blog post initially written in 2011 with special styles, and I see no reason to redo the styles.