Floats were designed to wrap text around an image, not to build a three-column layout - we've just been bending them to that job for a decade, with clearfix hacks holding the whole thing together. This year, with flexbox support landing solidly in current versions of Chrome, Firefox, Safari and Edge, we've started moving component-level layout - navigation bars, card rows, form controls - onto it in production.

The mental model

A flex container lays its direct children out along one axis, and - this is the part that actually saves time - it handles the leftover space for you. No more calculating percentages by hand or fighting collapsed margins.

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
Four boxes of different widths sitting in a single flex row
Flex items sizing themselves along one axis - no floats, no clearfix.

Three properties that solve most problems

justify-content handles spacing along the main axis, align-items handles the cross axis, and flex-wrap decides whether items are allowed to drop to a new line when they run out of room. That covers the vertical-centring problem that's plagued CSS forever:

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

Growing and shrinking with flex-grow / flex-shrink

Individual items can be told how to share extra space:

.sidebar { flex: 0 0 240px; }  /* fixed width, doesn't grow or shrink */
.content { flex: 1 1 auto; }  /* takes up whatever is left */

That single pattern replaces most of the "one fixed sidebar, one fluid content column" layouts we used to build with floats and a calculated margin-left.

Flexbox doesn't just make layout easier. It makes layout mean what it says.

Where it still falls short

Flexbox is one-dimensional by design - it's very good at a row or a column, less good at a true grid where items need to line up in both directions at once. For that, keep an eye on the CSS Grid specification, which is still in working draft but already looks like the right tool for page-level layout once browser support catches up. For now, flexbox is what we reach for on components, and floats still do a bit of the heavy lifting at the page level.

The three properties that solve 90% of layout questions

.row {
  display: flex;
  justify-content: space-between; /* main axis */
  align-items: center;            /* cross axis */
  gap: 16px;
}

justify-content and align-items together answer almost every "how do I center this" or "how do I space these evenly" question that used to require a stack of hacky floats, negative margins, or absolute positioning to fake.

flex-grow and flex-shrink are the part people skip

Most flexbox confusion comes from not setting flex-grow/flex-shrink explicitly and being surprised when items don't distribute space the way expected. A sidebar that should stay a fixed width while the main content fills the rest is exactly two lines:

.sidebar { flex: 0 0 240px; }  /* don't grow, don't shrink, base width 240px */
.main    { flex: 1; }          /* take up all remaining space */