I have always thought that the correct way to handle CSS floats was to use either a clear div, :after pseudo class, or overflow: auto on the parent. As I understand it clear is designed to clear floats and expand the parent element back to normal. That is it's purpose, yes?
Today I found heard of an alternate method of handling the float (and parent collapse): floating the parent as well to make it expand around the floated child.
How does this align with web standards? Is there even an official float/clear standard?
There is no particular standard here. Use whatever works in the situation.
Adding in extra HTML elements just to clear the float is frowned upon, but can occasionally be useful.
I personally like the prefer to use the Float Nearly Everything style of floating the parent, but it doesn't fit every situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With