How to create columns in HTML

Key takeaways:

  • Columns are created using <div class="column"> tag to define individual columns within a row.

  • Columns are grouped together with the <div class="row"> tag.

  • CSS properties like background-color and width are used to style and adjust the appearance of columns.

  • Multiple columns with varying widths can be created within a single row, offering flexible content layout options.

HTML columns are essential for organizing data in a structured manner, facilitating clear comparisons between two or more items. By dividing content into columns, you can enhance readability and streamline information presentation on our web pages. In this answer, we will explore how to create columns in an HTML page.

Defining columns in HTML

An HTML column is defined in the <div> tag using the class = "column" keyword. More columns can be added by adding more divs with the same class. The following syntax is used to add columns in HTML.

  • <div class="row"> tag is used to initialize the row where all the columns will be added.
  • <div class="column" > tag is used to add the corresponding number of columns. This class attribute is essential because it allows us to target these elements with CSS, making it easy to apply styles (such as width, background color, etc.) to all columns at once.
  • style="background-color:#aaa;" property is used to give color to the column.
  • Individual properties, such as width: 50%;, are added to the columns in the style sheet for that particular div.
Represents the columns defined in the row
Represents the columns defined in the row

Code example to create two columns

This example shows how to create two equal columns that take up 50% of the width each. The columns will be displayed side by side.

How to create multiple columns in HTML

HTML also allows the creation of more than two columns in a single row.


How to create three unequal columns

In this example, we have three columns with different widths: the first column is 20%, the second column is 30%, and the third column is 50%. This allows for a more flexible layout when more space is needed in one of the columns.

How to create a responsive two-column

Creating a responsive two-column layout involves using CSS to style the columns to display side-by-side on larger screens (e.g., desktops) and stack vertically on smaller screens (e.g., tablets and mobile phones). This is usually achieved with a combination of CSS Flexbox or CSS Grid for modern layouts and media queries for responsiveness.

To gain a deeper understanding of web development and enhance your skills, check out this comprehensive course: Learn HTML, CSS, and JavaScript from Scratch. This course provides step-by-step guidance to learn these technologies and build functional, responsive web applications.

Conclusion

In conclusion, creating columns in HTML is essential for organizing content and improving layout. Using CSS techniques like Flexbox and CSS Grid allows for flexible and responsive designs that adapt to different screen sizes. By applying media queries and modern layout methods, we can ensure the columns look great on both large and small devices, enhancing the user experience across all platforms.

Frequently asked questions

Haven’t found what you were looking for? Contact Us


How to write side by side in HTML

To display content side by side in HTML, you can use CSS Flexbox. By setting the container’s display property to flex, the child elements will automatically align in a row (side by side).

Check out our detailed Answer on How to make side by side divs in HTML.


How to align text in HTML

Use the CSS text-align property to align text within an element.

<div style="text-align: center;"> This will align the text in the center.</div>
<div style="text-align: right;">This will align the text in the right.</div>
<div style="text-align: left;">This will align the text in the left.</div>

What is column span in HTML?

The column-span property in CSS is used to define how we want to span the content across multiple columns when we are using a multi-column layout.

Check out our detailed Answer on What is the CSS column-span property?


Free Resources

Copyright ©2025 Educative, Inc. All rights reserved