Rows & Columns

Rows and columns are the foundation of modern website layouts. They help organize content into structured sections, making pages clean, readable, and responsive.

What Are Rows and Columns

A row is a horizontal section of a webpage that contains content. Inside each row, you can divide space into columns.

A column is a vertical section inside a row. Columns allow you to place content side by side, such as text, images, or cards.

Why Rows and Columns Are Important

They create a clean and organized layout
They improve readability and user experience
They help design responsive websites for mobile and desktop
They make content alignment easier

Basic Structure

A simple layout starts with a container. Inside the container, you create rows, and inside rows, you create columns.

Example structure:

Container
Row
Column
Column

Rows and Columns Using CSS Flexbox

Flexbox is a simple way to create rows and columns.

Example:

.container {
display: flex;
flex-direction: column;
}

.row {
display: flex;
}

.column {
flex: 1;
padding: 10px;
}

Explanation:

The container is set to column direction so rows stack vertically
Each row uses flex display to align columns horizontally
Columns share equal space using flex property

Rows and Columns Using CSS Grid

CSS Grid is a powerful layout system for creating rows and columns.

Example:

.container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}

Explanation:

The layout creates two equal columns
The gap adds spacing between columns
You can easily control rows and columns together

Responsive Design with Rows and Columns

Rows and columns should adjust for different screen sizes.

Example:

@media (max-width: 768px) {
.row {
flex-direction: column;
}
}

Explanation:

On smaller screens, columns stack vertically
This improves mobile viewing

Common Use Cases

Creating website sections like header, content, and footer
Building image galleries
Designing product cards
Creating blog layouts

Best Practices

Keep layouts simple and consistent
Use spacing to improve readability
Avoid too many columns on small screens
Test your design on different devices

Summary

Rows and columns help structure web pages in a clean and flexible way. By using Flexbox or Grid, you can easily build modern, responsive layouts suitable for all screen sizes.