Open In App
Related Articles

CSS grid-column-end Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The grid-column-end property explains the number of columns an item will span, or on which column-line the item will end. It supports three different types of values.

Syntax:  

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

Property Values:  

  • auto: The grid items will span in one column. It is the default value.
  • span n: It is used to specify the number of column items that will span.
  • column-line: It is used to specify on which column to end the display of the item, the user can set the end of the column.
     

Example: In this example, we are using grid-column-end: auto;

html




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS grid container Property
    </title>
 
    <style>
        .main {
            display: grid;
            grid-template-columns: auto auto auto;
            grid-gap: 20px;
            padding: 30px;
            background-color: green;
 
        }
 
        .GFG {
            text-align: center;
            font-size: 35px;
            background-color: white;
            padding: 20px 0;
        }
 
        .Geeks1 {
            grid-column-end: auto;
        }
    </style>
</head>
 
<body>
    <div class="main">
        <div class="Geeks1 GFG">1</div>
        <div class="Geeks2 GFG">2</div>
        <div class="Geeks3 GFG">3</div>
        <div class="Geeks4 GFG">4</div>
        <div class="Geeks5 GFG">5</div>
    </div>
</body>
</html>


Output: 

Example: In this example, we are using grid-column-end: span n;

html




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS grid container Property
    </title>
 
    <style>
        .main {
            display: grid;
            grid-template-columns: auto auto auto;
            grid-gap: 20px;
            padding: 30px;
            background-color: green;
 
        }
 
        .GFG {
            text-align: center;
            font-size: 35px;
            background-color: white;
            padding: 20px 0;
        }
 
        .Geeks1 {
            grid-column-end: span 3;
        }
    </style>
</head>
 
<body>
    <div class="main">
        <div class="Geeks1 GFG">1</div>
        <div class="Geeks2 GFG">2</div>
        <div class="Geeks3 GFG">3</div>
        <div class="Geeks4 GFG">4</div>
        <div class="Geeks5 GFG">5</div>
    </div>
</body>
</html>


Output: 

Example: In this example, we are using grid-column-end : column-line;

html




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS grid container Property
    </title>
 
    <style>
        .main {
            display: grid;
            grid-template-columns: auto auto auto;
            grid-gap: 20px;
            padding: 30px;
            background-color: green;
 
        }
 
        .GFG {
            text-align: center;
            font-size: 35px;
            background-color: white;
            padding: 20px 0;
        }
 
        .Geeks1 {
            grid-column-end: 3;
        }
    </style>
</head>
 
<body>
    <div class="main">
        <div class="Geeks1 GFG">1</div>
        <div class="Geeks2 GFG">2</div>
        <div class="Geeks3 GFG">3</div>
        <div class="Geeks4 GFG">4</div>
        <div class="Geeks5 GFG">5</div>
    </div>
</body>
</html>


Output: 

Supported Browsers: The browser supported by grid-column-end property are listed below: 

  • Google Chrome 57.0 and above
  • Edge 16.0 and above
  • Mozilla Firefox 52.0 and above
  • Safari 10.1 and above
  • Opera 44.0 and above
  • Internet Explorer not supported

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 09 Jun, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials