Grid Item


1

2

3

4

5


Child Elements (Items)

An HTML grid contains grid elements.

By default, a container has one grid item for each column and row. However, you can change the appearance of these grid items to make them cover more than one column or row if you like.


The grid-column Property:

The grid-column property tells us which column or columns an item should be placed in.

You specify the beginning and ending points for the item.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Important: The grid-column property is like a shortcut for grid-column-start and grid-column-end properties.

To position an object, you can either use the line numbers or employ the "span" keyword to specify how many columns the object should cover.


The grid-row Property:

The grid-row property tells you which row to put something in.

You specify the beginning and ending positions for the item.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Important information: The grid-row property is a way to make things fit neatly in a grid. It's like a shortcut for two other properties, grid-row-start and grid-row-end.

To position an object, you can either specify line numbers or utilize the term "span" to indicate how many rows the object should cover:


The grid-area Property

You can use the grid-area property as a shorter way to set values for grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties in HTML.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Naming Grid Items

You can also give names to grid items by using the grid-area property.

Header

Menu

Main

Right

Footer

You can use the grid container's grid-template-areas property to refer to grid items with specific names.

You can call specific grid items by using the grid-template-areas property of the grid container.

Every row is described using single quotation marks (' ').

The columns in each row are described within single quotation marks and separated by spaces.

Important: A period symbol means there is a grid item without a name.

To create two rows, specify the column for the second row within a separate pair of quotation marks:


The Order of the Items

The Grid Layout lets us put items wherever we want on a web page.

The initial element in the HTML code doesn't necessarily need to be the topmost item in the grid.

1

2

3

4

5

6

You have the ability to change the layout for specific screen sizes using media queries.