HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. CSS Grid Rows

CSS Grid

CSS Grid Rows

The CSS Grid Rows property is used to define the height and structure of rows in a CSS Grid layout.

Rows are created using the grid-template-rows property.

Just as columns control horizontal layout, rows control the vertical layout of grid items. The supporting concepts are explained in CSS Grid Columns and CSS Grid Gap.

With Grid Rows, you can:

  • Create multiple rows
  • Set fixed row heights
  • Create flexible row layouts
  • Build structured page sections
  • Control vertical spacing and alignment

Syntax

CSS Grid Rows Syntax

css

.container {
    display: grid;
    grid-template-rows: value;
}

CSS Grid Rows Example

css

.container {
    display: grid;
    grid-template-rows: 100px 200px;
}

Creates two rows: the first is 100px high and the second is 200px high.

Attributes

ValueDescriptionExample
pxFixed row height150px
%Percentage height50%
frFlexible fraction unit1fr
autoAutomatic height based on contentauto
repeat()Repeats row definitionsrepeat(3, 100px)

Example

CSS Grid Rows Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Grid Rows Example</title>
    <style>
        .container {
            display: grid;
            grid-template-rows: 100px 150px;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            border: 2px solid black;
            padding: 10px;
        }
        .item {
            background-color: lightblue;
            padding: 20px;
            text-align: center;
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item">Item 1</div>
        <div class="item">Item 2</div>
        <div class="item">Item 3</div>
        <div class="item">Item 4</div>
    </div>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
grid-template-rows57165210.1

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

  • grid-template-rows controls row heights.
  • auto allows rows to grow based on content.
  • fr can be used to create flexible row heights.
  • repeat() simplifies repetitive row definitions.
  • Rows work together with grid-template-columns to create complete grid layouts.

Equal Height Rows

Equal Height Rows

css

grid-template-rows: 1fr 1fr 1fr;

Creates three equal-height rows.

Using repeat()

repeat() Example

css

grid-template-rows: repeat(3, 120px);

Creates three rows, each 120px high.

Mixed Row Sizes

Mixed Row Sizes Example

css

grid-template-rows: 80px auto 150px;

First row = 80px
Second row = content-based height
Third row = 150px

Conclusion

The grid-template-rows property defines the height and structure of rows in a CSS Grid layout. By combining fixed heights, flexible units, and automatic sizing, you can create organized and responsive grid-based designs.

PreviousCSS Grid ColumnsNextCSS Grid Gap