One clearfix to rule them all

The concept of a clearfix didn’t really ring a bell for me until a couple of years into dedicated web work. It felt like a hack, maybe even a shortcut, and my instinct was that good old properly-syntaxed HTML and CSS would win the day.

I didn’t know what I was really talking about. Today, as we await final spec approval for Flexbox and eventual browser compatibility, we’re still in a place were block elements need to align themselves in some way.

If one doesn’t need to displace other elements, absolute positioning is always an option. But if vertical alignment needs to happen, you’re generally going to need to float something.

Published by Richard Tafoya

Richard Tafoya is a music journalist, photographer and web developer living in Los Angeles. This site is a mix of original posts and unedited versions of material created for other publications.
View more posts