Definition
The grid-column
CSS property is a shorthand property that combines both grid-column-start
and grid-column-end
properties. It is used in grid layouts to specify the starting and ending positions of a grid item along the horizontal axis.
The grid-column
property accepts values that represent the grid lines at which the grid item should start and end. Grid lines can be identified using line numbers, names of named grid lines, or the span
keyword to span across multiple grid tracks.
Here’s an example:
.grid-item {
grid-column: 2 / 4;
}
In this example, the grid-column: 2 / 4;
rule sets the grid item to start at the second grid line and end at the fourth grid line horizontally. This means the grid item will span across two grid tracks.
The grid-column
property provides a convenient way to specify both the starting and ending positions of a grid item along the horizontal axis. It simplifies the declaration of grid placement and allows for more concise grid layout code.