Table of Contents:

Course with employment: "Front-end developer profession"
Learn moreWhen browsing various websites on the internet, you can notice how neatly elements are arranged regardless of the screen size, including navigation, buttons, and text blocks. This is the responsibility of the CSS (Cascading Style Sheets) markup language. There are many approaches to style markup, but today we will discuss one of the most responsive – CSS Grid. This method allows you to create flexible and dynamic layouts that automatically adapt to different screen resolutions, ensuring the usability and attractiveness of the user interface. CSS Grid greatly simplifies the development process, allowing designers and developers to focus on the content and functionality of the site.
In this article, you will learn about:
- What is CSS Grid
- How to create it
- What properties does a grid container have?
- And what properties do grid items have?
- How to set margins between items
- How to align all items in a grid container at once
- How to align individual items
- What are nested grids
- What to remember
What is CSS Grid
Grid is a layout method that allows you to organize elements on a website in a table format. The main advantage of this table is its flexibility: you can merge cells, resize rows and columns, and adjust the margins between elements. Grids also adapt well to various screen sizes, ensuring responsiveness and improving user experience. Using grid layout allows for the creation of modern and functional web designs, making it a popular tool among developers.
The grid structure is similar to a familiar Excel file, with horizontal and vertical lines forming multiple cells. However, unlike Excel, grid cells contain website elements: text, images, buttons, HTML code blocks, and other components. These elements are referred to by specific terms in the context of grid layout.
- grid container — the most important element in the entire layout, it stores all the contents of the grid;
- grid cell — a unit of the grid, you can put one or more blocks of code here;
- grid line — a horizontal or vertical line dividing columns;
- grid row — a row of cells;
- grid column — a column of cells;
- grid element — any element of the site;
- grid area — a space of cells. In CSS, you can combine several cells into one and work with them as a single unit.
Here is how they are represented in the diagram:

CSS Grid differs from Flexbox in that it provides the ability to create two-dimensional layouts. This means you can control both rows and columns at the same time. Unlike Flexbox, where elements can only be arranged in one direction—vertically or horizontally—Grid offers much greater flexibility in organizing content. Grid lets you easily combine rows and columns, making it much easier to create complex and responsive interfaces. Grid allows web developers to effectively structure pages while improving both visual appeal and functionality.
Let's Get Started: Creating Our First Grid
To use Grid in practice, we'll need two files: HTML and CSS. Let's start with the basics—create an HTML file with the necessary content. You can use an online editor for convenience.
In this example, we've created several simple objects representing the Latin letters A, B, C, D, and E and placed them on separate lines. This allows us to clearly demonstrate the basic text elements and their structure.
Now it's time to declare the grid. To do this, create a style.css file in the same folder and add the following code to it:
At this point, no changes have been made. To make our grid more visible, let's add some styles: outline the container in green, and style all elements within it with a black dashed-dotted line. This will help visually highlight the structure and improve the perception of the content.

There are already improvements! However, our elements are still positioned by default, and a flexible layout is still out of the question. To learn how to customize a grid to suit your needs, you need to study the CSS Grid properties in detail.
Grid Container Properties
Grid container properties determine the parameters of the grid, including the number of rows and columns, their sizes, and the arrangement of elements within the grid. Properly setting these properties allows you to create a flexible and responsive structure that uses space efficiently. Using a grid container significantly simplifies the layout process, providing a high degree of control over the placement and behavior of elements on the page.
To create columns in your project, simply specify their sizes separated by a space. Sizes can be specified in various units of measurement, such as pixels, percentages, centimeters, and others. It is also possible to combine different units of measurement within a single property, which provides flexibility in layout customization. This allows the design to adapt to different devices and screen resolutions, improving the user interface and the experience of interacting with content. Proper use of column sizes helps to distribute space on a page more efficiently.
Percentages and fixed values can be used to create three columns with varying widths. The first column will occupy one-third of the screen width, the second column will have a fixed width of 100 pixels, and the third column will occupy the remaining space. This approach allows for flexible layout adaptation to different screen sizes while ensuring a convenient distribution of content. Using these values makes page structure more understandable and improves user experience.
If the combined width of all columns exceeds 100%, the third column will appear outside the container. This may result in incorrect content display on the page. For optimal perception and correct layout, it is important to ensure that the sum of the widths of all columns does not exceed 100%. Using responsive design will help avoid such problems and ensure correct display on various devices.

To prevent such situations, a new measurement element, fraction (fr), was introduced in the design. This unit of measurement allows you to effectively distribute available space on the screen by dividing it into several parts without having to manually adjust percentages. Using fractions simplifies the layout process, making it more flexible and easier to adapt to different screen sizes.
To achieve the desired space distribution in the table, we allocate one fraction of available space to the first column (1fr), two fractions to the third (2fr), and leave the middle column at a fixed width of 100 pixels. This approach allows you to create a harmonious arrangement of elements, optimizing the use of available space.
The result is true beauty - everything is neatly designed and placed in a frame.

Continuing. If we want to set the row sizes in our table, we need to use attributes that allow us to control the row height. This can be done with CSS by setting the desired values for the height property. This way, we can achieve the desired visual appearance of the table. Properly setting row sizes not only improves appearance but also increases the readability of the data. Use appropriate classes or IDs to apply styles to specific rows, which will provide greater control over the table formatting.
We notice that the two row sizes are the same - they are both 2fr. To optimize the code and avoid duplicating information, we can use the repeat function. This function takes two arguments: the row size in fractions and the number of repetitions.
Both long and short notations have their place and can be used depending on the context. For example, in this case, you can do without a function, but if you need to create, say, 10 columns, using a function will make the code more concise and readable. This approach not only improves the structure of your code but also its future maintainability.
The repeat function in JavaScript allows you to repeat a string a specified number of times. This is a useful tool for creating text patterns or for generating repeating elements. The function's syntax is string.repeat(number). Here, string is the text you want to repeat, and number is the number of repetitions. If you specify a negative value or a non-numeric value, the function will return an empty string. Using repeat helps you manage text data efficiently and reduces the time spent writing repetitive code. For example, the string «abc».repeat(3) will return «abcabcabc». Thus, the repeat function is a simple and convenient way to work with text in programming.

Note that the height of the last line E was not specified, so it retains the default value. This can impact the visual perception and readability of text. For optimal results, it is recommended to explicitly set line height, especially if it is important to the overall design and layout of your content. Specifying line height can improve the structure of text and make it more appealing to users. Grid layout has a unique feature that allows you to create areas and flexibly adjust their sizes. This functionality gives developers the ability to effectively organize content on web pages, ensuring responsiveness and ease of use. Grid systems are ideal for creating complex layouts, making the development process more intuitive and manageable. To create an area in CSS, you need to use the grid-area property for each element. You can choose any name that suits you as a parameter. Simply add the following code to any section of your CSS file: In the grid container, we form a "matrix" using these names. This approach allows you to organize content in a structured manner, ensuring easy navigation and visual appeal. Creating a matrix in a grid container not only improves aesthetics but also helps users better understand the information.
And there you have it! Our elements are organized according to a given template.

How it works. Each title in grid-template-areas is associated with a specific element. Identical names placed next to each other unite multiple cells into a single grid area. This allows for more complex and flexible layouts, ensuring a convenient distribution of space on the page. Proper use of names in grid-template-areas helps organize content better and makes it easier to read.
- Item A with the alias f occupies an area of 25 cells.
- Item B (i) occupies 9 cells.
- Item C (b) occupies 4 cells.
- Item D (o) occupies 1 cell.
- Item E (n) occupies 1 cell as well.
The grid-template property allows you to concisely define rows, columns, and entire areas in CSS Grid. This property simplifies the creation of flexible and responsive layouts by giving developers easy control over the placement of elements on the page. Using grid-template, you can specify the sizes and numbers of rows and columns, as well as define areas for more complex structures. This makes the layout process more intuitive and efficient, allowing you to achieve the desired result with minimal effort.
The shorthand for defining grid rows and grid columns is a convenient tool for creating grids in web design. Using this approach, developers can quickly and efficiently specify the number of rows and columns in CSS Grid. This simplifies the layout process, allowing you to focus on design and functionality. Proper use of the grid form helps optimize code and improve its readability, which in turn has a positive impact on SEO. Make sure your grid is responsive and easily adapts to different screen sizes, which is an important aspect of modern web design.
Creating a table in HTML can be significantly simplified with a single line of code. We can specify the number of rows and columns using a slash to separate them. As an example, consider creating a grid consisting of three rows, each occupying 1fr, and two columns, each occupying 2fr. This approach allows you to quickly and efficiently organize content on the page, while ensuring the flexibility and adaptability of the layout.

The grid-template property in CSS supports the repeat function, which allows you to effectively define repeating patterns for grids. Using repeat, you can shorten your code and improve readability by specifying the number of repetitions and cell sizes. This is especially useful when creating complex layouts, where consistent cell sizes can significantly simplify the development process. Using the repeat function in grid-template helps create responsive and flexible grids, which is an important aspect of modern web design.
The result remains consistent.

The shorthand for grid areas is a compact and efficient way to define a grid in CSS. Using this form, developers can quickly and easily define the sizes and positions of elements in a grid layout. It allows for simplified code, making it more readable and structured. Implementing the shorthand for grid areas helps optimize page loading and improve the user experience. Using this technique, you gain flexible layout control, which is especially important for responsive design. The shorthand also makes it easier to maintain and change styles in the future, making it an essential tool for web developers.
The shorthand for CSS supports the declaration of grid areas. To do this, you must specify the grid-area property for each grid item. This allows for simplified and structured code, making it more readable and easier to edit. Proper use of the grid-area property ensures the efficient placement of elements within the grid, which contributes to a better user experience on the website. Profit is a key concept in business and finance, denoting the income remaining after all expenses are deducted. Understanding profit is essential for successful company management, as it reflects the company's operational efficiency and financial health. Profit can be expressed in various forms: gross profit, operating profit, and net profit. Each of these profit types provides unique insights into the financial health of a business and helps in strategic decision-making. Increased profit can be achieved through cost optimization, increased sales, or improved service quality. In modern business, it is important not only to strive for profit growth, but also to maintain it at a stable level to ensure the sustainability and development of the company in the long term.

Properties Grid Items
These properties allow you to specify precise coordinates for the browser to position elements on the page. Two points must be specified: the start line, where the element begins, and the end line, to which it extends. This principle applies both horizontally and vertically. Correct use of these properties can significantly improve the structure and visual perception of a web page, which in turn affects user experience and SEO optimization.

To move an element horizontally, You must use the CSS property «transform». With «translateX()», you can specify an offset of an element along the X axis. For example, if you want to move an element to the right by 100 pixels, use the following code:
«`css
.element {
transform: translateX(100px);
}
«`
To move to the left, simply specify a negative value:
«`css
.element {
transform: translateX(-100px);
}
«`
You can also animate this offset by adding CSS animations or transitions. For example:
«`css
.element {
transition: transform 0.5s ease;
}
.element:hover {
transform: translateX(100px);
}
«`
This way, the element will smoothly move to the right when hovered over. Using the «transform» property to move elements horizontally helps create dynamic and interactive interfaces, improving user experience on the website.
Defines the starting position of the columns.
Sets the end position (line) for the columns.
The combined property of grid lines columns: start and end
The combined property of grid lines columns in CSS allows you to set both the start and end of a line for a column in the grid. This property simplifies the process of creating complex layouts by allowing developers to precisely define how elements will be placed within the grid. Using the grid-column-start and grid-column-end properties, you can effectively control the placement of elements, which is a key aspect when working with CSS Grid Layout.
Using a combined property of grid column lines eliminates redundancy in code and makes it more readable. For example, instead of specifying the start and end lines separately, you can use the grid-column property, which significantly simplifies the styling process. This property accepts values as numbers, line names, or combinations of both, giving developers flexibility in controlling the placement of elements.
Using a combined property, you can easily adapt layouts to different screen sizes, which is especially important in the context of the growing popularity of mobile devices. Using grid grids allows you to create responsive and functional designs that easily scale and remain aesthetically pleasing on any device.
Thus, the combined property of grid lines for columns is a powerful tool for web developers, allowing them to effectively manage the arrangement of elements and improve the quality of their code.
Vertical arrangement of elements is an effective way to organize content. This approach improves the perception of information and makes the text more readable. Vertical arrangement is convenient for users, as it facilitates navigation and promotes better assimilation of the material. Using a vertical format can be especially useful on mobile devices, where space is limited. At the same time, it is important to remember the harmony and balance in the arrangement of elements, which will help create an attractive and functional interface.
Sets the start position for a line of text.
Sets the end position (line) for rows.
The combined property of grid lines for rows allows you to specify the beginning and end of rows in CSS Grid Layout. This property simplifies the process of creating layouts, allowing developers to clearly define on which lines the grid items should begin and end. By using this property, you can optimize content placement, improve code readability, and simplify its maintenance. Proper use of the combined grid line property helps create more structured and responsive designs, which is an important aspect of modern web development.
There is one common property that unites all four main elements.
Now let's look at how to apply these properties to the first three elements of our letter structure. This will allow us to better understand how to control the styles and behavior of elements on the page. Using CSS properties to customize the visual presentation of these elements will help improve their perception and user interaction.
This code determines the positions at which letters should be placed in the grid. It ensures the correct placement of characters, which is an important element for the visual design and readability of the text. Correct configuration of letter positions in the grid helps improve the perception of information and makes the content more attractive to users.
- Element A occupied the area from the first to the fourth line — both horizontally and vertically.
- Element B occupied the area from the fourth to the sixth line horizontally and from the first to the third line vertically.
- Element C occupied the area from the fourth to the fifth line horizontally and from the third to the fourth line vertically.
- Well, the rest were located by default 🙂

Grid-gap (margins)
The grid-gap property allows you to customize the spaces between elements in a CSS Grid container. This is achieved using two parameters: the first, which determines the distance between rows, and the second, which is responsible for the spacing between columns. Proper use of grid-gap improves the visual perception of content and allows you to create more structured and attractive layouts. Use this property to optimize the placement of elements and improve user experience.
- column-gap — the distance between columns;
- row-gap — the distance between rows.
The gap property in CSS, similar to grid-template, has a shorthand notation. In this notation, the column-gap and row-gap parameters can be specified separately by a space. This allows you to more compactly specify the distances between elements in the grid, simplifying the layout process and improving the readability of the code. Using the gap shorthand is a convenient way to adjust both vertical and horizontal spacing in CSS Grid and Flexbox, making it much easier to manage the space between elements.

Grid Container Alignment
Now that we've covered the properties of elements, let's discuss how to properly align them within a container or area. Elements can be aligned in a variety of ways, helping to create a more harmonious and user-friendly page structure. Effective alignment improves user experience and facilitates better content perception. Let's look at basic methods of element alignment, such as using flexbox, grid, and other CSS techniques, to achieve the desired result.
Horizontal alignment of elements within a given area is an important task in web design. This process ensures a page's aesthetic appeal and improves user experience. Proper horizontal alignment helps create a clear content structure, making information easier to digest. It is important to consider various alignment methods and techniques to achieve the best results in the design and layout of web pages.

Stretching elements to fill the entire width of a grid cell
Using CSS Grid allows you to effectively manage the layout of a web page. One of the key features is stretching elements to fill the entire width of a grid cell. This is achieved using CSS properties such as `grid-column` and `width`.
To ensure that an element takes up the entire width of a grid cell, you can specify properties that allow it to adapt to the size of its parent container. This will result in elements that look aesthetically pleasing and modern, which will positively impact the user experience and the overall perception of the site.
Use properties such as `grid-template-columns` to define the width of columns and `grid-column: 1 / -1` to stretch an element to fill the available width. This will help create a harmonious and orderly design.
In addition, it is important to consider the responsiveness of elements so that they display correctly on different devices. Stretching elements to fill the full width of a grid cell not only improves the appearance but also increases the functionality of your web resource.

The arrangement of elements on the left side of a grid cell or area plays an important role in creating a visually appealing and functional design. Proper alignment of objects ensures harmony and ease of perception of the content. Using CSS Grid allows you to precisely control the placement of elements, which improves user experience and promotes efficient site navigation. Elements positioned on the left can attract attention and simplify interaction, which improves the overall efficiency of the web design.

Centering elements in grid cells or areas is an important task in web design. Proper centering improves visual perception and creates a more harmonious interface. To achieve this effect, you can use CSS properties such as align-items and justify-items, which allow you to effectively position content within a given area. Centering elements not only enhances aesthetic appeal but also improves user experience by making it easy to navigate and interact with a web page.

The element is aligned to the right side of a grid cell or area.
Vertical alignment of elements within an area is an important aspect of web design that ensures Harmonious content placement. Proper vertical alignment helps create a visually appealing interface, improves readability, and enhances user experience. Using CSS properties such as flexbox or grid makes it easy to control the vertical alignment of elements, ensuring their even distribution and proper positioning within their container. This, in turn, improves user experience and increases the efficiency of interaction with the site.

The elements stretch to cover the entire width of the grid cell. This allows for efficient use of the available space, ensuring harmonious distribution of content. This approach improves the appearance and functionality of the layout, making it more attractive and convenient for users.

The elements are located at the top of the grid cell.

Centering elements in grid cells is an important aspect of web design. It helps achieve a harmonious and balanced appearance of the page. To achieve this effect, you can use CSS properties such as `display: grid` and corresponding alignment properties, including `align-items` and `justify-items`. These properties ensure that elements are precisely placed in the center of the cell, creating a visually appealing layout. Proper centering improves user experience and makes the interface more intuitive.

Elements are positioned at the bottom of the grid cell.
Horizontal alignment of elements within a container is an important aspect of web design. This process allows you to organize content in a way that makes it more structured and aesthetically pleasing. Proper alignment helps users better perceive information, facilitates navigation, and improves the overall interaction with the site. Using appropriate CSS properties to align elements will help create a harmonious and user-friendly interface.

Elements are placed on the left side of the grid container.

Items can be centered within a grid container using appropriate CSS properties. To do this, use properties such as justify-items and align-items, which allow you to align content horizontally and vertically. Setting these properties to "center" will ensure that items are placed symmetrically within the container, improving visual perception and organizing the layout. Thus, the correct use of CSS Grid for centering elements contributes to a more harmonious and structured web page design.

Positioning all elements on the right side of the grid container optimizes the use of space and improves the visual structure of the page. This approach allows you to focus users' attention on key interface elements, which improves navigation ease and enhances user experience. Properly configured grid container can also impact SEO, as it simplifies content indexing by search engines.

Elements are placed along the left and right margins. The first element is located closer to the beginning, and the last one is closer to the end. This distribution helps create a balanced and organized presentation of content, improving visual perception and ease of navigation.

Distributing elements with equal space between them and half the space from the edges is an important aspect of web design. This approach helps create a harmonious layout, ensuring visual balance and easy-to-read content. Using this technique helps avoid interface clutter and improves user experience. Proper distribution of space improves the readability of text and the perception of images, which in turn has a positive effect on user experience and SEO optimization.

Even distribution of space between elements and from the edges is an important aspect of web design. It helps create a harmonious and visually appealing interface. Proper placement of elements improves readability and enhances user experience. Using CSS properties such as margin and padding, you can effectively control the distance between elements and from page edges. Optimal distribution of space makes information easier to perceive and makes the interface more organized. Vertical alignment of elements within a container is an important task in web design, helping to create a visually appealing and organized interface. This process ensures an even distribution of space between elements, which improves user perception of the content. Proper vertical alignment improves navigation and makes the site look more professional. Using CSS Flexbox and Grid is one way to achieve effective vertical alignment of elements within containers. First, let's increase the height of the container by changing the height parameter. This will improve the visual perception of the page and maximize the use of space for content. Container height plays a key role in design, as it affects the structure and functionality of the web page, ensuring ease of navigation and emphasizing important elements. Setting the height parameter will help create a more harmonious and attractive design, which in turn will have a positive impact on user experience and SEO optimization.

At the moment, the elements are simply distributed the length of the container. Now let's consider the possibility of using the following properties to improve their display:

All elements are placed at the top of the container. This helps to achieve orderliness and ease of use of the interface. Proper arrangement of elements at the top of the container improves information perception and page navigation.

All elements are placed in the center of the grid container. This helps achieve harmonious visual perception and promotes more efficient content organization. Centering elements in the grid container improves user experience and makes the site more attractive to visitors. Proper placement of elements can also have a positive impact on SEO, as it helps improve the perception of information.

The elements are placed along the top and bottom edges. The first element is closer to the beginning, and the last one is closer to the end. This arrangement creates a clear hierarchy and simplifies the perception of information.

Distributing elements with equal spaces between them, as well as taking into account half of this space from the edges, allows you to create a harmonious and visually attractive design. This approach ensures an even distribution of space, which improves the perception of content and increases the ease of navigation. Using equal spacing between elements helps create a neat and professional design that will improve the user experience and optimize the site for search engines.
Aligning Grid Items
CSS Grid properties are applied to individual grid items, so you don't have to specify settings for the entire container, but for a specific item, such as an A. This allows for more precise control over the placement and behavior of each item within the grid, ensuring flexible and responsive design.
Horizontal alignment of grid items is an important task for creating a harmonious and user-friendly interface. Proper alignment helps improve the perception of content and simplifies navigation. Using CSS properties such as justify-content and align-items, you can easily achieve the desired arrangement of elements in the grid system. This not only improves visual aesthetics but also contributes to a better user experience. Effective alignment of grid elements allows you to create a more structured and organized layout, which in turn can positively impact the SEO position of the site.

Item A occupies the entire length of the grid area.

Item A is placed in the center of the grid area. This position allows it to stand out and provides a harmonious distribution of space in the design. Centering item A in the grid system improves visual perception and ease of navigation, creating balance between other elements on the page. Optimal placement of elements in the grid area plays a key role in creating an effective and attractive interface.

Item A is at the beginning of the grid area.

Item A is at the bottom of the grid area.
Vertical alignment of grid items is an important aspect in creating a responsive and aesthetically pleasing design. Proper vertical alignment helps improve the perception of content and ensures the harmonious arrangement of elements on the page. Using CSS Grid, you can easily achieve the desired result by setting properties like align-items and justify-items to adjust the position of elements within the grid container. This allows you to create user-friendly and functional interfaces, which is especially important for users interacting with the web page. Effective alignment not only enhances visual appeal but also improves the overall user experience.

Item A takes up the entire width of the grid area.

Item A is in the center of the grid area.

Element A is at the top of the grid area.

Item A is at the bottom of the grid area.
Grid within a Grid: Nested Grids
In CSS, a grid can be nested, meaning that one grid container can contain another. To better understand this concept, consider modifying our HTML framework by adding an extra level of elements. Nested grids allow you to create more complex and flexible layouts, simplifying the process of managing the arrangement of elements on the page. Proper HTML structure and the use of nested grids in CSS will help you achieve the desired visual design and improve the user experience.
In the CSS file, we will create a basic 3x3 grid. This will allow you to effectively organize the content on the page, ensuring the convenient placement of elements. Using a 3x3 grid will improve the visual structure and navigation, and also increase the ease of information perception. Setting up the grid will include defining cell sizes, padding, and borders, which will help achieve a harmonious and modern design. Proper implementation of the grid will help improve the user experience and enhance the page's SEO optimization.
We have received a unique matryoshka doll, which stands out for its originality and quality of execution. This matryoshka combines traditional elements of Russian folk art and modern design solutions. Each layer of the matryoshka is crafted with attention to detail, making it not only beautiful but also a valuable item. This matryoshka doll will make a wonderful gift or a decorative element highlighting Russia's rich culture.

For element D, we'll set the display: grid property to create an additional grid inside it. To define row and column properties, we use the subgrid parameter, which will inherit the parent grid's settings. This ensures consistency and simplifies the layout process, allowing child elements to follow the same rules as their parent. Using subgrid significantly improves the flexibility and control of the grid structure, which is especially useful when creating complex layouts.

Now you can confidently manage elements E, F and G, setting them Unique placement within element D, which is also converted to a grid. For example, let's set element E's starting position from the second vertical grid line to the third.
The internal elements are organized in a nested grid layout. This approach allows for efficient use of space and improves the structure of the content, ensuring its logical placement. The nested grid allows for more flexible control over the positioning of elements, making the interface more convenient and intuitive for users.

What you need Remember
Today we looked at CSS Grid, its functionality, structure, and customization options. The CSS grid system allows you to effectively organize space on a web page, giving developers powerful tools for creating responsive and complex layouts. The main components of a grid include a grid container and grid items, which interact with each other to form a visual structure. We also discussed key properties such as grid-template-rows, grid-template-columns, and grid-area, which allow you to flexibly control the arrangement of elements. Understanding the principles of CSS Grid is an important step in creating modern and user-friendly interfaces.
- Grid Layout in CSS is a flexible layout in which elements are arranged in a table-like structure. A table consists of cells that can be collected into entire areas.
- To create a grid, you need to add the line display: grid to the CSS markup file.
- A grid consists of a parent container and elements nested within it. Elements can occupy several cells, which are collected into columns, columns, or areas.
- A fraction is a unit of measurement in CSS created for convenience—to allow you to specify the relationship between elements without manually adjusting percentages.
- A grid can contain another grid—this design is called a nested subgrid.
- The main properties of a grid container are: grid-template, grid-template-columns, grid-template-rows, grid-template-areas. They allow you to specify the sizes of columns, rows, or entire areas.
- The column-gap property is responsible for the gaps between grid columns, and the row-gap property is responsible for the gaps between rows.
- You can horizontally align container items using justify-items and justify-content, and vertically using align-items and align-content.
- You can adjust the location of items from a specific grid line using the following properties:
- along the horizontal axis: grid-column-start, grid-column-end, grid-column;
- along the vertical axis: grid-row-start, grid-row-end, grid-row;
- or the general grid-area property.
- You can align a specific grid item using justify-self (horizontally) and align-self (vertically).
Learn more about coding and programming in our Telegram channel. Subscribe to the latest news and useful materials!
Read also:
- Indentation rules: how to make your layout flexible and avoid mistakes
- Vue.js: what is it, how is it structured, and how is it different from React
- Is it worth reading books about programming and IT?

