3 ms·
All elements in a container floats to the top of the container and right or left (depending on the text direction ltr or rtl) of the previous element. If there
by tdudhhu 3y ago
All elements in a container floats to the top of the container and right or left (depending on the text direction ltr or rtl) of the previous element. If there is no space left it will move below the previous elements.
If an element has `display: block`, it will fill up all horizontal space so every element after it will float below that element.
That is why it is called `float`. It's how the position of elements is calculated.
If you use `float:left|right` it forces the float of that element to float left or right before all other elements in the same container.
That is what float means.
But of course this does not work anymore if your container uses flex or grid.
- ourmandave 3y agoYou can still float elements in a subcontainer inside a flex container.