You are on page 1of 8

CSS Grid

A grid can be defined as an intersecting set of horizontal lines and


vertical lines.
CSS Grid layout divides a page into major regions.
It defines the relationship between the parts of a control built
from HTML primitives in terms of layer, position, and size. Grid property
offers a grid-based layout system having rows and columns.
 It makes the designing of web pages easy without positioning and
floating.
Similar to the table, it enables a user to align the elements into rows
and columns. But compare to tables, it is easy to design layout with
the CSS grid.
We can define columns and rows on the grid by using grid-template-
rows and grid-template-columns properties.
CSS Grid
It can define the grid container by setting the display property
to grid or inline-grid on an element.
Grid container contains grid items that are placed inside rows and
columns.
shorthand properties:
grid-template-columns: It is used to specify the size of the columns.
grid-template-rows: It is used to specify the row size.
grid-template-areas: It is used to specify the grid layout by using the
named items.
grid-auto-rows: It is used to specify the automatic size of the rows.
grid-auto-columns: It is used to specify the automatic size of the
columns.
grid-auto-flow: It is used to specify how to place auto-placed items
and the automatic row size.
CSS Grid
Property Description
Columns-gap Specifies the gap between the columns
gap A shorthand property for the row-gap and the column-gap properties
grid A shorthand property for the grid-template-rows, grid-template-
columns, grid-template-areas, grid-auto-rows, grid-auto-columns, and
the grid-auto-flow properties
Grid-area Either specifies a name for the grid item, or this property is a
shorthand property for the grid-row-start, grid-column-start, grid-row-
end, and grid-column-end properties
Grid-auto- Specifies a default column size
columns
grid-auto-flow Specifies how auto-placed items are inserted in the grid
Grid –auto-row Specifies a default row size
Grid -columns A shorthand property for the grid-column-start and the grid-column-
end properties
Grid-column-end Specifies where to end the grid item
CSS Grid
Property Description

Grid-column-gap Specifies the size of the gap between columns


Grid-column-start Specifies where to start the grid item
Grid-gap A shorthand property for the grid-row-gap and grid-column-
gap properties
Grid-row A shorthand property for the grid-row-start and the grid-row-
end properties
Grid-row-end Specifies where to end the grid item
Grid-row-gap Specifies the size of the gap between rows
Grid-row-start Specifies where to start the grid item
Grid-template A shorthand property for the grid-template-rows, grid-template-
columns and grid-areas properties
Grid-template-area Specifies how to display columns and rows, using named grid items

Grid-template- Specifies the size of the columns, and how many columns in a grid
columns layout
CSS Layout
CSS layout is easy to design. We can use CSS layout to design our web
page such as home page, contact us, about us etc.
There are 3 ways to design layout of a web page:
HTML Div with CSS: fast and widely used now.
HTML Table: slow and less preferred.
HTML Frameset: deprecated now.
A CSS layout can have header, footer, left pane, right pane and body
part.
CSS Layout
Tag Explanation

header It specifies a header for a section or for a document.

section It represents a section in a document.

nav It specifies a container for navigation links.

article It specifies an independent self-containing article.

aside It specifies a tag for content aside from main content (like a sidebar).

footer It specifies a footer for a section or for a document.

details It specifies a tag for additional details.

summary It specifies a header for the  <details> element.

You might also like