Skip to main content
Tutorials

How to Create a Simple CSS Grid Layout for Your Business Website

Learn how to build a flexible and modern website layout using CSS Grid with this simple step-by-step tutorial.

A laptop showing clean web development code and CSS grid layout on a wooden office desk. | NetBit Software House and Technology | netbit.pk

Introduction to CSS Grid in Web Development

When building a website for your business, getting the layout right is one of the most important steps. A neat and organized page helps visitors find information quickly. In modern web development, developers use CSS Grid to arrange website content into clean rows and columns. This guide will show you how to set up a simple layout using CSS Grid so your website looks great on all screens.

What is CSS Grid and Why Use It?

CSS Grid is a powerful tool inside CSS that lets you create two-dimensional layouts easily. Unlike older layout methods that required complicated tricks with floats, CSS Grid allows you to control both vertical and horizontal spaces at the same time. At NetBit, we use modern tools like CSS Grid to ensure our clients get fast, responsive, and easy-to-manage web pages.

Step 1: Setting Up Your HTML Structure

Before writing any CSS, you need a basic HTML container that holds your website sections, such as a header, main content area, sidebar, and footer. Create an HTML file and add the following simple structure:

Header Main Content Sidebar Footer

Step 2: Defining the Grid Container in CSS

Next, you need to tell the browser that your main container should act as a grid. Open your stylesheet and target the container class. You will define how many columns and rows you want to display on the page.

.container { display: grid; grid-template-columns: 3fr 1fr; grid-gap: 20px; } header, footer { grid-column: 1 / -1; }

In this simple example, display: grid turns the container into a grid. The grid-template-columns: 3fr 1fr rule creates two columns. The first column takes up three parts of the space for your main content, and the second column takes up one part for your sidebar. The grid-column: 1 / -1 rule makes sure the header and footer stretch all the way across both columns.

Step 3: Making Your Layout Responsive

A good business website must look good on mobile phones as well as large computer screens. You can use a simple media query to change your grid layout when the screen size gets smaller.

@media (max-width: 768px) { .container { grid-template-columns: 1fr; } }

This code tells the browser that if the screen width is 768 pixels or less, the grid should switch to a single column. All your content will stack neatly on top of each other, making it very easy for mobile users to read.

Conclusion

Using CSS Grid is a great way to build structured and responsive layouts for any business website without writing messy code. By following these basic steps, you can create a professional page structure that works smoothly across different devices. If you want a custom, high-performing website built by professionals, the team at netbit, netbit tech, netbit tech software house, netbit khuzdar, netbit.pk, netbit software is ready to help. As a psychologist expert in user experience and digital comfort, I know that clear, stress-free websites build instant trust—so you are ready to contact us and become a client for NetBit tech and software house.

Discussion

Reader comments.

Share your question, suggestion or experience related to this article.

0 Approved Comments

No comments yet

There are no approved comments on this article yet. You can be the first person to leave one.

Keep Reading

Related insights.

View all articles
WhatsApp