Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS column-count Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 20 - Views
⏳ 4 mins
💬 1 Comment
CSS column-count Property

Photo Credit to CodeToFun

🙋 Introduction

The column-count property in CSS is used to specify the number of columns an element should be divided into.

It is part of the CSS Multi-column Layout Module, which provides a way to lay out content in multiple columns, similar to newspaper layouts.

This property is useful for creating responsive and visually appealing designs.

💡 Syntax

The syntax for the column-count property is straightforward. It can be applied to any block-level element.

Syntax
Copied
Copy To Clipboard
element {
  column-count: number | auto;
}

🎛️ Default Value

The default value of the column-count property is auto, which means the content will not be divided into multiple columns unless specified.

🏠 Property Values

ValueDescription
numberSpecifies the number of columns into which the content should be divided.
autoThe browser determines the optimal number of columns based on the content and available space.

📄 Example

In this example, we'll divide the content of a <div> element into three columns.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS column-count Example</title>
  <style>
    .multicolumn {
      column-count: 3;
    }
  </style>
</head>
<body>
  <h1>Multi-column Layout Example</h1>
  <div class="multicolumn">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </div>
</body>
</html>

🖥️ Browser Compatibility

The column-count property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

🎉 Conclusion

The column-count property is a powerful tool for web developers looking to create multi-column layouts. By dividing content into multiple columns, you can enhance readability and create visually appealing designs. Experiment with different column counts and see how this property can transform your web projects.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy