CSS Multiple Columns: Build Layouts Like a Magazine

Have you ever wondered how websites, blogs, or even online magazines achieve that newspaper-style multi-column layout?

You scroll and suddenly, text flows side by side, not top to bottom.

It’s not a trick.
It’s not JavaScript.
It’s pure CSS magic—with multi-column layout.

Let’s dive into this underused, powerful feature of CSS.

📖 Bonus: Learn from the Best

If you’re serious about mastering HTML & CSS with visually rich, beginner-friendly content, I highly recommend this book:

👉 HTML and CSS: Design and Build Websites by Jon Duckett

HTML and CSS Book Cover

A full-color guide with diagrams that helped me truly understand what “designing with CSS” means.

✨ What is CSS Multi-Column Layout?

The CSS multi-column layout allows content to be displayed across multiple columns—just like you’d see in a magazine or newspaper.

div {
  column-count: 3;
}

This breaks the content inside the <div> into 3 vertical columns.

🔍 Key Properties You Should Know

Property Description
column-count Sets number of columns
column-gap Gap between columns
column-rule Shorthand for column rule width, style, color
column-span Span an element across columns
column-width Suggest optimal width for each column
columns Shorthand for column-width + column-count

🧪 Real Example: 3 Column Layout

<style>
.columns {
  column-count: 3;
  column-gap: 40px;
  column-rule: 2px solid #ccc;
}
</style>

<div class="columns">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Integer nec odio. Praesent libero. Sed cursus ante dapibus diam.
  ...
</div>

This will:

  • Divide the text into 3 vertical columns
  • Add a 40px gap between them
  • Add a subtle vertical line between columns

🧩 Column Spanning Example

Sometimes you want a heading to stretch across all columns:

h2 {
  column-span: all;
}

Use this for section headers in your multi-column layout.

📏 Set Width Instead of Count

You can suggest the width of each column instead:

.columns {
  column-width: 120px;
}

The browser will calculate how many columns can fit in the container.

💡 Pro Tips

  • Combine column-width and column-count for responsive behavior.
  • Avoid placing interactive elements (like forms) inside columns—they can behave unpredictably.
  • Use break-inside: avoid; to prevent content from being split awkwardly.

🧠 Interview Questions

  1. What does column-count do in CSS?
  2. How can you set the gap between columns?
  3. What is column-rule, and how is it used?
  4. How do you make a heading span across multiple columns?
  5. What’s the difference between column-count and column-width?
  6. How do you prevent an element from breaking inside a column?

💬 Final Thoughts

Multi-column layouts aren’t just for print-inspired designs. They’re useful, readable, and elegant, especially for blog posts, portfolios, or any content-heavy website.

And the best part? It takes just a few lines of CSS.

If you’re ready to design smarter, faster, and cleaner, don’t forget to grab a copy of:

👉 HTML and CSS by Jon Duckett — one of the most beautifully designed dev books out there.

Similar Posts