Skip to main content
Syllabus
On this page

Why Layout Evolved: Tables, Floats, Flexbox and Grid

Badar KhalilUpdated October 1, 2026 8 min read

CSS Layout Evolution: Why We Needed Flexbox and Grid

The CSS layout evolution is the story of how web developers went from abusing HTML tables to build page structure, to hacking floats, and finally to using purpose-built layout systems: CSS Flexbox and CSS Grid. Understanding this history is not trivia. It explains why Flexbox behaves the way it does, why old tutorials tell you to use clearfix hacks, and when you should pick Flexbox, Grid, or both in modern CSS layout.

What You Will Learn

  • Why HTML table layouts were popular and why they failed
  • How float-based layouts worked, and every hack they needed (clearfix, fixed widths, faux columns)
  • How inline-block, display: table and absolute positioning tried to fix the gaps
  • What problems Flexbox solved and which problems it deliberately does not solve
  • Why CSS Grid arrived and how Flexbox vs Grid divide the work
  • What the modern layout toolkit looks like (gap, container queries, subgrid, logical properties)

Era 1: Table-Based Layouts (Mid-1990s to Early 2000s)

In the early web, CSS was either missing or unreliable across browsers. Developers needed columns, sidebars and headers, and the only HTML element that arranged content in rows and columns was <table>. So they used tables for everything: the whole page was one giant table, often nested three or four levels deep, with transparent 1px spacer GIFs to push things around.

HTML
<table width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2">Header</td>
  </tr>
  <tr>
    <td width="200">Sidebar</td>
    <td>Main content</td>
  </tr>
  <tr>
    <td colspan="2">Footer</td>
  </tr>
</table>

Why Table Layouts Failed

  • Content mixed with presentation: the HTML described how things looked, not what they meant.
  • Accessibility problems: screen readers announce tables as data grids, so a layout table creates confusing, noisy output.
  • Not responsive: a table cannot reflow its columns into a single column on a phone.
  • Source order is locked: you cannot display the sidebar after the content without rewriting the markup.
  • Heavy and slow: browsers often had to download and calculate the whole table before painting anything.
  • Maintenance nightmare: redesigning meant editing every HTML file.

Important: tables are not bad. They are still the correct element for real tabular data (invoices, schedules, comparison grids). The mistake was using them for page layout.

Era 2: Float-Based Layouts (Early 2000s to 2014)

With CSS support improving, the web standards movement pushed developers to separate structure (HTML) from presentation (CSS). The tool they reached for was the float property. The irony: float was designed in CSS1 only so text could wrap around an image, like a magazine layout. Developers repurposed it to place whole columns side by side.

CSS
.sidebar { float: left;  width: 25%; }
.main    { float: right; width: 75%; }

/* The infamous clearfix, needed so the parent
   does not collapse to zero height */
.clearfix::after {
  content: '';
  display: block;
  clear: both;
}

The Hacks Floats Required

  • Clearfix: floated children are taken out of normal flow, so the parent collapses unless you clear them.
  • Percentage maths: columns had to add up to exactly 100% or the last column dropped below the others.
  • Box-sizing issues: padding and borders added to width, breaking the maths until box-sizing: border-box became standard.
  • Faux columns: columns never had equal height, so developers faked it with repeating background images.
  • No real vertical centering: centering something vertically needed negative margins or other tricks.
  • Grid frameworks built on floats: early 12-column systems (and the first versions of popular frameworks) all depended on floats.

Era 3: The In-Between Hacks

Before Flexbox was usable, developers tried several other workarounds. You will still find them in legacy codebases, so you should be able to recognise them.

TechniqueHow it workedMain weakness
display: inline-blockItems sit in a line like wordsWhitespace gaps between items in the HTML
display: table / table-cellCSS borrows table behaviour without table markupHard to wrap, awkward to reorder
Absolute positioningPlace items with top, left, transformItems leave the flow, parent does not size to content
CSS frameworks (grid systems)Pre-built float columnsExtra markup and class names for everything

Era 4: Flexbox (The Flexible Box Layout Module)

CSS Flexbox started as early drafts around 2009, went through several syntax rewrites, and became stable and unprefixed across all major browsers by about 2015. Its goal was simple: give developers a real layout mode where a container can distribute space among its children and align them, without hacks.

Problems Flexbox Solved

  • Distributing space: items can grow to fill leftover space or shrink to avoid overflow.
  • Alignment: centering horizontally and vertically takes two lines of CSS.
  • Equal-height columns: items in a row stretch to the same height by default.
  • Reordering: visual order can differ from source order (use carefully for accessibility).
  • Direction independence: the same CSS works for row or column, and respects writing direction (including right-to-left languages).
CSS
.row {
  display: flex;
  gap: 1rem;
}
.sidebar { flex: 0 0 25%; }
.main    { flex: 1; }

No clearfix, no percentage maths, no fixed heights. The container controls its children.

Era 5: CSS Grid (2017 to Today)

Flexbox is one-dimensional: it lays items out along a single line (a row or a column) and can wrap onto more lines, but each line is mostly independent. Whole-page layouts need control over rows and columns at the same time. CSS Grid was built for that and shipped in all major browsers within a few weeks of each other in March 2017.

CSS
.page {
  display: grid;
  grid-template-columns: 1fr 3fr;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
  gap: 1rem;
}

Flexbox vs Grid: Which One Should You Use?

QuestionFlexboxGrid
Dimensions1D (row or column)2D (rows and columns together)
Sizing approachContent-first: items decide, container adaptsLayout-first: you define the tracks, items fit in
Best forNavbars, toolbars, button groups, card rows, centering, form rowsPage layouts, galleries, dashboards, anything with aligned rows and columns
WrappingWrapped lines do not align with each otherItems stay aligned to the same tracks

Rule of thumb: if you are arranging items in one line, start with Flexbox. If you are building a layout with both rows and columns, start with Grid. In real projects you will nest them: Grid for the page frame, Flexbox inside each component.

Timeline Summary

PeriodDominant techniqueKey idea
Mid-1990s to early 2000sHTML tablesUse table cells as page columns
Early 2000s to 2014Floats + clearfixRepurpose text wrapping for columns
Around 2015 onwardFlexboxOne-dimensional layout with space distribution
2017 onwardCSS GridTrue two-dimensional layout
2020sFlexbox + Grid + container queries + subgridComponent-driven, intrinsic, responsive layout
  • gap: spacing between items without margin hacks; works in Flexbox, Grid and multi-column.
  • Container queries: components respond to the size of their container instead of the viewport, which pairs naturally with Flexbox components.
  • Subgrid: nested grids can share the parent's tracks, fixing misaligned card content.
  • Logical properties: margin-inline, padding-block and inset-inline-start adapt to writing direction.
  • Intrinsic sizing helpers: clamp(), min(), max(), aspect-ratio for fluid responsive design.
  • Browser DevTools layout debugging: flex and grid badges and overlays make layout bugs visible (covered in the last topic of this chapter).

Common Mistakes and Misconceptions

  • "Flexbox replaced Grid" or the reverse. They are complementary, not competitors.
  • Using floats for layout in new code. Floats are still valid for wrapping text around an image, which is their real job.
  • Using tables for layout because email needs it. That is a special case; for web pages use CSS layout.
  • Using Flexbox for everything. Complex two-dimensional layouts become fragile when forced into nested flex rows.

Key Takeaways

  • Tables, floats and positioning hacks were workarounds because CSS had no real layout system.
  • Flexbox gives you one-dimensional layout with powerful space distribution and alignment.
  • Grid gives you two-dimensional layout; use it together with Flexbox.
  • Knowing the history helps you read legacy CSS and choose the right tool today.
Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Exercise: Convert a Float Layout to FlexboxHTML

The code below uses floats and a clearfix to build a two-column layout. Rewrite it with Flexbox: make .wrapper a flex container, remove the floats and the clearfix, keep the sidebar at 25% width using flex, let .main fill the remaining space, and add a 16px gap between the columns.

Try it Yourself HTML
Output

Press Run to execute.

Show expected output
Two columns side by side, sidebar about 25% wide, main fills the rest, 16px gap between them, both columns have equal height, no float and no clearfix remain.

This is a self-check — compare your result with the expected output above.

Was this page helpful?