- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS grid - row-gap
CSS row-gap property defines the size of the gap between rows.
To ensure compatibility with legacy websites, the gap property in CSS Grid was initially named grid-row-gap, and browsers will still accept grid-row-gap as an alias for row-gap.
Possible Values
<length-percentage> − The percentage value for row-gap determines the width of the gap between rows in a grid, relative to the height of the grid container.
Applies to
Multi-column elements, flex containers, grid containers.
DOM Syntax
object.style.rowGap = "<length>|<percentage>";
CSS row-gap - <length>
The following example demonstrates that row-gap: 30px property adds the 30px gap between rows in the grid layout −
<html> <head> <style> .grid-container { display: grid; grid-template-columns: auto auto auto; row-gap: 30px; color: white; text-align: center; } .grid-container > div { background-color: red; border: 2px solid blue; padding: 10px; } </style> </head> <body> <div class="grid-container"> <div>Grid item 1</div> <div>Grid item 2</div> <div>Grid item 3</div> <div>Grid item 4</div> <div>Grid item 5</div> <div>Grid item 6</div> </div> </body> </html>
CSS row-gap - <percentage>
The following example demonstrates that row-gap: 40% property adds the 40% gap between rows in the grid layout −
<html> <head> <style> .grid-container { display: grid; grid-template-columns: auto auto auto; row-gap: 40%; } .grid-container > div { background-color: red; color: white; padding: 10px; border: 2px solid blue; text-align: center; } </style> </head> <body> <div class="grid-container"> <div>Item 1</div> <div>Item 2</div> <div>Item 3</div> <div>Item 4</div> <div>Item 5</div> <div>Item 6</div> </div> </body> </html>
CSS row-gap - Flex Layout
The following example demonstrates how to use row-gap property is used to add a row gap between adjacent flex items.
The display: flex and flex-flow: wrap property is used to create a flex container. If the items do not fit within the container's width, they will move to the next row.
The flex: 1 1 auto property allows the flex items to grow or shrink as needed.
<html> <head> <style> .flex-container { display: flex; flex-wrap: wrap; width: 250px; row-gap: 20px; } .flex-container > div { border: 2px solid red; background-color: pink; flex: 1 1 auto; padding: 10px; } </style> </head> <body> <div class="flex-container"> <div>Flex Item 1</div> <div>Flex Item 2</div> <div>Flex Item 3</div> <div>Flex Item 4</div> <div>Flex Item 4</div> <div>Flex Item 5</div> </div> </body> </html>
CSS column-gap - Grid Layout
The following example demonstrates that the row-gap: 30px property adds 30px vertical space between the grid items −
<html> <head> <style> .grid-container { display: grid; height: 150px; grid-template-columns: 100px 1fr; grid-template-rows: repeat(3, 1fr); row-gap: 30px; } .grid-container > div { border: 2px solid red; background-color: pink; } </style> </head> <body> <div class="grid-container"> <div>Flex Item 1</div> <div>Flex Item 2</div> <div>Flex Item 3</div> <div>Flex Item 4</div> <div>Flex Item 4</div> <div>Flex Item 5</div> </div> </body> </html>