In this section, we will learn what the grid-column-start property is and how to use it in CSS.
Click here to run the example of grid-column-start property.
CSS grid-column-start Property Definition and Usage
After we’ve created our CSS grid, by default, grid-items will be automatically positioned on each cell of that grid. But this is the default behavior and we can decide where on the grid we want each grid-item to be positioned.
Now, using the `grid-column-start` property, we can declare the line number or line name that the left edge of the target item should be placed on.
Also, there’s another property named `grid-column-end` which declares the line number or line name that the right edge of the target item should be placed on.
Note: These two elements usually come together.
CSS grid-column-start Property Syntax
grid-column-start: auto|span n|column-line-name| column-line-number;
CSS grid-column-start Property Value
- start-column-line-number: We know that a grid has multiple vertical lines, right? So using this value, we can determine what line number the left edge of the target item should be placed on.
- start-column-line-name: As explained in `grid-template-columns` section, when creating a grid, we can actually name the lines of that grid. So “start-column-line-name” is actually the name of the grid’s line that we want the left edge of the target item to be placed on.
Also, there’s a keyword named “span” which can be used as the value of this property. Here’s the syntax:
grid-column-start: span number-of-tracks;
- span: this is the keyword and that means span a number of tracks (the number itself is declared using the number-of-track).
- Number-of-track: this is the number of tracks we want the grid-item to expand on.
Example= grid-column-start: span 3; // means expand the target item on 3 columns.
Note: the value “auto” is the default value. This means the item will span on one column.
Example: grid-column-start property in CSS
See the Pen grid-column-start property in CSS by Omid Dehghan (@enjoytutorials1) on CodePen.