CSS grid-column-end Property Tutorial

In this section, we will learn what the grid-column-end property is and how to use it in CSS.

Click here to run the example of grid-column-end property.

CSS grid-column-end 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-end` property, we can declare the line number or line name that the right edge of the target item should be placed on.

Also, there’s another property named `grid-column-start` which declares the line number or line name that the left edge of the target item should be placed on.

Note: These two elements usually come together.

CSS grid-column-end Property Syntax

grid-column-end: auto|span n|column-line-name| column-line-number;

CSS grid-column-end Property Value

  • column-line-number: Using this value, we can determine what line number the right edge of the target item should be placed on.
  • column-line-name: this value is actually the name of the grid’s line we want the right edge of the target item 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-end: span number-of-tracks;
  • span: this is the keyword and that means a number of tracks.
  • Number-of-track: this is the number of tracks we want the grid-item to expand on.

Example= grid-column-end: 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-end property in CSS

See the Pen grid-column-end property in CSS by Omid Dehghan (@enjoytutorials1) on CodePen.

Leave a Reply