C.W.K.
Stream
Lesson 04 of 04 · published

The Legacy Vocabulary: float, clear, table-display, and Why They're Retired

~11 min · float, clear, table-display, legacy

Level 0Markup Novice
0 XP0/34 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"Knowing the legacy isn't nostalgia — it's so you recognize the patterns when you read old code and don't reach for them in new code."

Why This Lesson Exists

Three layout techniques carried the web from 1996 to about 2017: floats, inline-block, and display: table. Each was a clever workaround for the fact that CSS had no real layout primitive. Flexbox (2017 baseline) and Grid (2017 baseline) replaced them. We name them here so you (1) recognize them when reading older codebases, (2) understand the original intent, (3) and don't accidentally reach for them in new code.

Float: The Image Wrap That Became Layout

float: left and float: right were designed for one thing: wrapping text around an image or pull-quote. The element moves to the side, and inline content (text) flows around it. This is still float's correct, supported use.

The web took float far beyond that. Two-column layouts, three-column layouts, navigation bars, image galleries, entire page structures — all built on float. The reasons it worked:

  • Floats are taken out of normal flow.
  • Adjacent floats sit side by side until they fill the container.
  • clear: both forces an element below preceding floats.

The reasons it was terrible for layout:

  • The parent collapsed to zero height because its children were out of flow ("clearfix" hacks fixed this).
  • Vertical alignment was impossible.
  • Equal-height columns required JavaScript or table-display tricks.
  • Source order had to match visual order — no way to reorder.
  • Centering with floats required negative-margin hacks.

Where Float Is Still Right

Wrapping a paragraph around a small image or pull-quote. That's it.

The Clearfix: A Hack You'll Still See

Because floats removed children from flow, parents collapsed. The clearfix was an after-pseudo-element trick to force the parent to contain its floated children:

The modern equivalent is display: flow-root on the parent. One declaration, no pseudo-element. You'll see clearfix in older codebases; recognize it, don't add it.

inline-block Layouts

Around 2010, inline-block became the float alternative for grid-like layouts. The technique:

It worked, but inline-block has the inline whitespace gap problem (Lesson 2): the source whitespace between elements renders as a visible space, breaking pixel-perfect grids. Workarounds: source-comment the whitespace, set font-size: 0 on the parent, or use negative margins. All hacks. Flexbox and Grid eliminated this entirely.

display: table and table-cell

CSS lets you make any element behave as a table cell without using actual <table> markup. display: table + display: table-cell gave you:

  • Vertical alignment via vertical-align: middle.
  • Equal-height columns automatically.
  • No clearing needed.

This was the "clever" pre-Flexbox solution to centering and equal-height layout. Now Flexbox and Grid do the same things more cleanly. You'll occasionally still see display: table-cell for vertical centering in very specific cases (single-line text in a fixed-height container) — Flexbox with align-items: center replaces this too.

The Mantra For Reading Old Code

If old code uses floats for layout, the modern replacement is almost always Flexbox or Grid. If you're refactoring, the order is: identify the layout intent (one-dimensional row/column? two-dimensional grid?), choose the modern primitive, replace. Don't add a clearfix to make floats work; replace the floats.

Why You Still Need To Know This

You'll inherit codebases written in 2014. You'll read tutorials from 2013 that show float: left for layout. You'll see Bootstrap 3 still floating around in legacy projects. Understanding the legacy means you read these without confusion, and you know what to replace them with.

Tables For Tables (Not Layout)

One final point: <table> markup is for actual tabular data. Spreadsheet-style information with rows and columns. Don't use <table> for layout; that's a 1998 pattern that's wrong on every dimension (accessibility, maintainability, responsiveness). Do use <table> for actual tables — and learn the modern table CSS (border-collapse, caption, thead/tbody/tfoot, sticky headers via position: sticky).

Pippa's Note

Zero floats in the cwkPippa codebase. The avatar grid on the landing page is display: grid; the message rows in the chat panel are display: flex; the council brain picker is a display: grid with template columns. Every legacy pattern has a modern replacement that's shorter, more readable, and more responsive. The only float in the project is in the cwk-site essay content where a small image wraps text — float's original job.

Code

Float, used correctly·css
/* Float — used correctly, wrapping text around a figure */
figure.pull-quote {
  float: right;
  width: 200px;
  margin: 0 0 1rem 1.5rem;
  font-style: italic;
  border-left: 4px solid #5BA3D8;
  padding-left: 1rem;
}

/* The surrounding text flows around the floated figure */
article p { line-height: 1.7; }
Float vs Grid — same layout, different decade·css
/* LEGACY pattern — three-column layout with float (don't write this in 2026) */
.col {
  float: left;
  width: 33.333%;
  padding: 0 1rem;
  box-sizing: border-box;
}
.row::after {                    /* clearfix */
  content: '';
  display: block;
  clear: both;
}

/* MODERN equivalent — Flexbox or Grid */
.row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}
/* Half the CSS, no clearfix, automatic equal heights,
   responsive with one media query (or container queries). */
Centering — legacy vs modern·css
/* LEGACY pattern — vertical centering with display: table */
.table-center {
  display: table;
  width: 100%;
  height: 200px;
}
.table-center .cell {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
}

/* MODERN equivalent — Flexbox */
.modern-center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
}

/* Or, the most concise — Grid */
.modern-center-grid {
  display: grid;
  place-items: center;
  height: 200px;
}

External links

Exercise

Find or write a three-column layout using floats with a clearfix. Then rewrite it in Flexbox (display: flex; gap: 2rem; each child gets flex: 1). Then rewrite again in Grid (display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem). Compare the CSS line count, what happens when you add a fourth column, and what happens on narrow screens (with a single media query for grid-template-columns).
Hint
The Grid version is usually the shortest. The Flexbox version is more flexible when children have different sizes. The float version is the longest by far and has the most fragility — that's why it's retired.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.