In this article, we learn about what is CSS grid layout? and what are the main use of the CSS grid on web pages or web development with the help of an example?

What is the Concept of CSS Grid?
The Grid Layout system offers the grid-based layout system, which means it provides rows and columns to create web pages. It helps to reduce the use of float and positioning systems.
CSS Grid Layout Example
Here the complete layout of CSS Grid with source code, Will explain it below paragraphs.
See the Pen Complete CSS Grid Layout by Bikash Panda (@phpcodertech) on CodePen.
Introduction to Concept of Grid Elements
The grid layout is collection of one or more grid elements.
1 2 3 4 5 6 |
<div class="grid-container"> <div class="grid-item">1</div> <div class="grid-item">2</div> <div class="grid-item">3</div> <div class="grid-item">4</div> </div> |
For displaying the HTML grid elements we use display
CSS property.
1 2 3 |
.grid-container { display: grid; } |
1 2 3 |
.grid-container { display: inline-grid; } |
Using display CSS property grid containers automatically changes the elements to grid items.
Grid Columns
The vertical line of Grid Items are called Grid Columns.
Image Ref: https://www.w3schools.com/

Grid Rows
The horizontal lines of grid items are called rows.

Concept of Grid Layout Spaces
We can also change the spaces between Grid lines,
grid-column-gap
grid-row-gap
grid-gap
Grid Spaces Example
Here is the property for grid column gap
1 2 3 4 |
.grid-container { display: grid; grid-column-gap: 60px; } |
Here is the property for grid row gap
1 2 3 4 |
.grid-container { display: grid; grid-row-gap: 60px; } |
Gap or complete spaces between all grids and also set for both row and columns.
1 2 3 4 |
.grid-container { display: grid; grid-gap: 60px 120px; } |
Grid Lines
If you create the lines between columns then it is called column line and if row then called row lines.

CSS for both row grid lines and column grid lines,
grid item at column line 1, and end on column line 3:
1 2 3 4 |
.item1 { grid-column-start: 1; grid-column-end: 3; } |
Grid item at row line 1, and end on row line 3:
1 2 3 4 |
.item1 { grid-row-start: 1; grid-row-end: 3; } |
CSS Grid Layout Browser Support
Here is the complete concept of CSS Grid system where we work with web pages.
Also check:
- CSS background-image Properties
- Login with Google Account using PHP Step by Step
- Display Current Date and Time in HTML using JavaScript
Happy Coding..!
5 Replies to “Concept of CSS Grid Layout With Example”