Introduction

In web design, a grid is a layout technique that provides an ordered framework for placing pieces on a webpage by classifying material into rows and columns. A grid can be defined as a set of intersecting horizontal and vertical lines. The CSS Grid layout divides the page into main areas. It defines the relationship between parts of a control built from HTML primitives in terms of class, position, and size. The Grid property provides a grid-based layout system with rows and columns. It makes it easy to design web pages without positioning or floating. One popular grid system that gives developers control over the dimensions, orientation, and alignment of grid elements inside the grid container is CSS Grid Layout.
Brief Explanation of CSS Grid
'Grid layout' the web page is multi-dimensional. To work with grids, we need a grid container & grid item.
Properties of grid containers
This property can only be applied to grid containers.
The properties are:
- Display: grid
- Grid-template-columns
- Grid-template-rows
- Column-gap/row-gap/gap
Display: It specifies the targeted component to be grid.
Syntax
display: grid;
Grid-template-columns: It specifies the number of columns along with their width.
Syntax
grid-template-columns: value;
Grid-template-rows: It specifies the number of rows along with their height.
Syntax
grid-template-rows: value;
Example
- grid-template-columns: 200px 200px 200px;
- grid-template-rows: auto auto auto;
- grid-template-columns: repeat(3, auto);
Column-gap/row-gap/gap: It specifies the gap between grid-item. The gap is the short-hand property of column-gap and row-gap.
Properties of grid-items: These properties we can apply only on grid-items
- grid-row-start: It specifies the starting row (syntax grid-row-start: 1)
- grid-row-end: It specifies the last row (syntax grid-row-end: 4)
- grid-column-start: It specifies the starting column (syntax grid-column-start: 2)
- grid-column-end: It specifies the last column (syntax grid-column-end: 4)
- grid row: It is a shorthand property of grid-row-start and grid-row-end (syntax grid-row: 1/4)
- grid-column: It is a shorthand properties of grid-column-start and grid-column-end (syntax grid-column: 2/4)
- grid-area: It is a shorthand properties of grid-row-start,grid-column-start,grid-row-end,grid-column-end (syntax grid-ares: 2/4/1/4)


Join the conversation! Your thoughts help the community grow.