Before Flexbox became popular, creating CSS equal height columns was surprisingly annoying. Developers used floats, fake table layouts, and sometimes even JavaScript just to make columns line up properly.
Thankfully, modern CSS makes this much easier today.
In this tutorial, you’ll learn multiple ways to create equal height columns using CSS, including Flexbox and Grid — with practical examples you can use in real projects.
Why Equal Height Columns Matter
Equal height columns make layouts look:
- cleaner
- more professional
- balanced
They are commonly used in:
- pricing tables
- card layouts
- blog grids
- dashboard designs
Method 1: How to Create CSS Equal Height Columns Using Flexbox
Flexbox is the easiest and most modern solution.
In most real-world projects, Flexbox is usually the fastest way to solve equal height layout problems.
HTML
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<div class="container"> <div class="column"> <h2>Column 1</h2> <p>Short content.</p> </div> <div class="column"> <h2>Column 2</h2> <p> This column has more content which makes it taller. Flexbox automatically keeps both columns equal height. </p> </div> </div> |
CSS
|
1 2 3 4 5 6 7 8 9 10 |
.container { display: flex; gap: 20px; } .column { flex: 1; padding: 20px; background: #f4f4f4; } |
How It Works
When using:
|
1 |
display: flex; |
all child elements automatically stretch to the same height.
This is why Flexbox is the preferred solution.
Result
Both columns become equal height automatically — even if the content length is different.
If you inspect modern websites today, you’ll notice that Flexbox is used almost everywhere for card layouts and UI alignment.
Method 2: Equal Height Columns Using CSS Grid
CSS Grid is another excellent modern approach.
CSS
|
1 2 3 4 5 |
.container { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } |
Grid items naturally stretch to equal height in the same row.
When to Use Grid Instead of Flexbox
Use Grid when:
- Building full page layouts
- Creating complex responsive grids
- Working with rows and columns together
Use Flexbox when:
- Aligning small UI components
- Building navbars
- Creating card rows
Method 3: Equal Height Cards Layout
This is a practical real-world example.
HTML
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<div class="cards"> <div class="card"> <h3>Basic Plan</h3> <p>Simple features for beginners.</p> </div> <div class="card"> <h3>Pro Plan</h3> <p> Advanced features with additional tools and premium support. </p> </div> <div class="card"> <h3>Enterprise</h3> <p> Full business solution for large teams and organizations. </p> </div> </div> |
CSS
|
1 2 3 4 5 6 7 8 9 10 11 |
.cards { display: flex; gap: 20px; } .card { flex: 1; background: white; padding: 20px; border: 1px solid #ddd; } |
Responsive Equal Height Column
For mobile responsiveness:
|
1 2 3 4 5 6 7 8 |
.container { display: flex; flex-wrap: wrap; } .column { flex: 1 1 300px; } |
This allows columns to stack on smaller screens.
Common Mistakes
1. Not Using display:flex
Without Flexbox, equal heights usually won’t work automatically.
2. Adding Fixed Heights
Avoid this:
|
1 |
height: 400px; |
Avoid fixed heights unless you absolutely need them. They often create spacing issues on smaller screens and can break responsive layouts.
3. Forgetting flex:1
|
1 2 3 |
.column { flex: 1; } |
This helps columns share equal width.
Flexbox vs Old CSS Methods
Older methods included:
- Floats
- Table layouts
- JavaScript height matching
Modern CSS Flexbox replaces all of these with much cleaner code.
Browser Support
Flexbox and Grid are supported in all modern browsers including:
- Chrome
- Firefox
- Edge
- Safari
Best Method in 2026
✅ Recommended:
Use Flexbox for equal height columns
For most layouts, I’d recommend using Flexbox first because it’s simpler and easier to debug.
It is:
- Simple
- Responsive
- Widely Supported
- Easy to Maintain
Where You’ll Actually Use This
CSS equal height columns are commonly used in:
- Pricing tables
- Feature cards
- Blog post grids
- Dashboard widgets
- SaaS landing pages
Frequently Asked Questions (FAQ)
Q1. How do I make all columns the same height in CSS?
Use Flexbox:
|
1 2 3 |
.container { display: flex; } |
Q2. Does CSS Grid create equal height columns automatically?
Yes. Grid items in the same row stretch equally by default.
Q3. Should I use JavaScript for equal height columns?
No. Modern CSS handles this easily without JavaScript.
Final Thoughts
Creating CSS equal height columns used to require hacks and unnecessary complexity. Today, Flexbox and Grid make this problem much easier to solve.
For most projects, Flexbox is usually the quickest and cleanest solution. Once you start using it regularly, building responsive layouts becomes much more enjoyable.
For most layouts:
- Use Flexbox for simple rows
- Use Grid for complex layouts
Once you understand these techniques, building responsive layouts becomes much easier.
