CSS Portal

CSS grid-auto-rows Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The grid-auto-rows property defines the default sizing behavior for any rows that the grid must create implicitly — that is, rows that are not explicitly declared in the grid’s template but are generated by the placement of items (or by the auto-placement algorithm) when content extends beyond the defined track list. It does not change rows you explicitly created with the template; instead it provides the fallback height for each automatically added row so the layout engine knows how tall those new tracks should be when they are introduced during layout.

Because implicit rows are created dynamically, grid-auto-rows is particularly important for grids where items can flow beyond the initial template (for example when items are positioned with indices or when many items are placed by the auto-placement algorithm). The property interacts with how the grid fills space: explicit rows defined in grid-template-rows always take precedence, and any excess items or tracks are fulfilled by the implicit rows sized according to this property. The auto-placement behavior itself — whether items generate new rows or columns and how they are added — is controlled by grid-auto-flow, so the practical effect of the implicit-row size depends on that placement strategy.

There is a direct counterpart for columns — grid-auto-columns — and together these properties determine how the grid grows when content doesn’t fit the explicit track definitions. Practically, choosing an appropriate implicit-row size helps avoid unexpected overflow or excessive empty space and ensures a predictable rhythm when the grid expands. Because changes to this property affect how many pixels (or logical units) are reserved for each generated row, adjusting it can trigger relayout and should be used deliberately in responsive designs where the number of implicit tracks may change with content or viewport size.

Definition

Initial value
auto
Applies to
Grid containers
Inherited
No
Computed value
The percentage as specified or the absolute length
Animatable
Yes
JavaScript syntax
object.style.gridAutoRows

Interactive Demo

One
Two
Three
Four
Five

Syntax

grid-auto-rows: <track-size>+
where 
<track-size> = <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( [ <length> | <percentage> ] )
where 
<track-breadth> = <length-percentage> | <flex> | min-content | max-content | auto
<inflexible-breadth> = <length> | <percentage> | min-content | max-content | auto
where 
<length-percentage> = <length> | <percentage>

Values

  • autoThe size of the rows is determined by the size of the container and the size of the contents of the elements in the column. As a maximum, it is identical to the value of max-content , but at least it represents the largest minimum size. Automatic row sizes can be stretched using align-content properties and justify-content. This is the default value.
  • length / percentageSpecifies the size of implicitly generated strings using a valid length value, or a percentage value. The value must be positive.
  • flexNon-negative value in "flexible" units of measure fr ( fractional unit ). Each implicitly created row occupies a part of the remaining space in the container of the layout grid in proportion to the specified coefficient. For example, when using the value 1fr 2fr , implicitly generated lines will occupy ⅓ and ⅔ of the remaining space, respectively. The total size of such rows or columns is subtracted from the available space, which gives the remaining space, which is then divided between the rows and columns of flexible size in proportion to their coefficient. Values ​​between 0fr and 1fr have somewhat special behavior, when the sum of the coefficients is less than 1, they will occupy less than 100% of the remaining space. When the available space is infinite (the width or height of the container of the layout grid is undefined), the size of the lines of the grid of flexible size is determined by their contents while maintaining the appropriate proportions.
  • max-contentA keyword that sets the size of each row based on the largest element in the row.
  • min-contentA keyword that sets the size of each row based on the smallest element in the row.
  • minmax (min, max)Functional notation that defines a range of sizes greater than or equal to min and less than or equal to max . If max is less than min , then max is ignored, and the function is treated as min . The value in "flexible" units of measurement as the maximum value sets the coefficient of flexibility of the line, this is unacceptable to determine the minimum.
  • fit-content (length | percentage)This is the formula min (max-content, max (auto, argument)) , which is calculated by analogy with auto (that is, minmax (auto, max-content) ), except that the size of the string is clamped by the argument value, if it is larger than the automatic minimum.

Example

<div class='grid'>
<div class='item'>1 - explicit row</div>
<div class='item'>2</div>
<div class='item'>3</div>
<div class='item'>4</div>
<div class='item'>5</div>
<div class='item'>6</div>
<div class='item'>7 - implicit row</div>
<div class='item'>8 - implicit row</div>
<div class='item'>9 - implicit row</div>
</div>
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 150px 100px; /* two explicit rows */
    grid-auto-rows: 80px;          /* implicit rows will be 80px high */
    gap: 12px;
    max-width: 900px;
    margin: 36px auto;
    padding: 12px;
    box-sizing: border-box;
}

.item {
    background: linear-gradient(135deg, #6fa8dc 0%, #3b82f6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    text-align: center;
}

/* Optional responsive tweak */
@media (max-width: 520px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

Browser Support

The following information will show you the current browser support for the CSS grid-auto-rows property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!