Open In App

CSS grid-row-end Property

Last Updated : 27 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The grid-row-end property in CSS defines the grid item’s end position within a grid row by specifying the inline edge of its grid area.

Syntax

grid-row-end: value;
  • Default Value: auto 

Property Values: 

  • auto: The grid items span for the default value of one row.
  • span int: It specifies the number of rows the item will span.
  • integer: It specifies the row on which the item ends.
  • initial: It sets the grid-row-end property to its default value.
  • inherit: The grid-row-end property is inherited from its parent.

Note: Don’t initialize the height and width of the items of the container explicitly. If initialized, the span effect can’t be observed.

Example 1: This example describes the container items without the grid-row-end property. 

<!DOCTYPE html>
<html>

<head>
    <title>
        CSS grid-row-end 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;
        }
    </style>
</head>

<body>
    <div class="main">
        <div class="GFG">1</div>
        <div class="GFG">2</div>
        <div class="GFG">3</div>
        <div class="GFG">4</div>
        <div class="GFG">5</div>
    </div>
</body>

</html>

Output: 

Example 2: This example describes the container items with the grid-row-end: span n property. 

<!DOCTYPE html>
<html>

<head>
    <title>
        CSS grid-row-end 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-row-end: span 2;
        }
    </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-row-end property are listed below: 

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

CSS grid-row-end Property – FAQs

What does the grid-row-end property do in CSS?

The grid-row-end property specifies the ending row line for a grid item in a grid container. It defines where an item should stop vertically within the grid, determining how many rows the item spans.

How do I control where a grid item ends using grid-row-end?

You can control the ending position of an item using grid-row-end like this: grid-row-end: 4; , which makes the item stop at the 4th row line.

What’s the difference between grid-row-start and grid-row-end?

Grid-row-start specifies where an item begins, while grid-row-end specifies where it stops. Both properties work together to define the item’s vertical span across rows.

Can I use grid-row-end with the span keyword?

Yes, you can use span with grid-row-end to control how many rows the item should span, for example: grid-row-end: span 3; to make the item span 3 rows from its starting point.

How does grid-row-end interact with grid-template-rows?

Grid-row-end respects the sizes set by grid-template-rows, ensuring the item stops at the appropriate row line according to the template’s row definitions.



Next Article

Similar Reads

three90RightbarBannerImg