I guess you can say the same thing about the infamous <FONT> tag. But if you want styling information directly in the HTML, you can still do it with the "style"-attribute, using marginally more syntax. e.g. <div style="display:table"> or <div style="display:flex; flex-direction:row"> instead of table <table> where html table semantics are not appropriate.
I do find flexbox a much nicer model than tables, but I guess that comes down to taste. A flex is basically like a table with either a single column or a single row, and a bit more fine-grained control.
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Co...
I wish it was intuitive to me, so I could use it quickly and without turning my css code into a mess.
It's all based on rows and columns, that collapse based on screen width. Plus, utility classes for all the alignment positions.
You'll still run into the issue of way too many nested div's, but I find myself more productive than trying to flexbox everything by hand. ymmv.
> but just looking at the raw HTML always leaves me a bit confused how elements on the page will relate to each other.
Generally you shouldn't be able to determine layout from the raw HTML. HTML should be semantic. CSS determines layout and styling.
Suppose you have the following desktop layout:
ONE TWO THREE FOUR FIVE
and you want to turn it into the following mobile layout: O N E
TWO THREE
FOUR FIVE
With floats, you can achieve that by overriding only a few properties, primarily 'width'. But if you asked me to do it with either flexbox or grid, I'd have to think for a bit.Flexbox is good for things that need internal flexibility in one dimension. Grid is for things that have a relatively static, two-dimensional layout. Floats are perfect for things that need to shuffle across dimensions, and I don't see any reason to avoid using them. After all, it's not as if floats are un-semantic or anything.
* Float will alight "one" to the left or right with a gap next to it, while flex can stretch, center, or align the element differently.
* If the elements are different heights, they'll stack up very differently.
I need to apply justify|align|content|items in the browser to make it do what I want. I can't for the life of me remember what they do.
But the underlying principles are neat. Flexbox gives me a container and an arbitrary number of children of various types which I can then position to my hearts delight. And things tend to fall in to place without me over-specifying every case.
As long as I'm working along one dimension, that is.
> but just looking at the raw HTML always leaves me a bit confused how elements on the page will relate to each other.
You say it like it's a bad thing. Chances are the relations are flexible.
One does run in to issues when the Flexbox rules apply across the bounds of components (e.g. Vue or React components) which makes composition difficult. Can be avoided by clearly separating layout from the rest. The S in SOLID applies to CSS as well.
I found the Flexbox Zombies course to be helpful for that: https://flexboxzombies.com
It's free right now too.