{"id":321902,"date":"2020-09-28T07:35:12","date_gmt":"2020-09-28T14:35:12","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=321902"},"modified":"2021-08-30T13:34:14","modified_gmt":"2021-08-30T20:34:14","slug":"row-gap","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/r\/row-gap\/","title":{"rendered":"row-gap"},"content":{"rendered":"\n

The row-gap<\/code> property in CSS sets space (formally called “gutters”) between rows in CSS Grid, Flexbox, and CSS Columns layouts.<\/p>\n\n\n\n\n\n\n\n

\"\"<\/figure>\n\n\n\n

You can think of row-gap<\/code> as the “next generation” or successor of grid-row-gap<\/code> which was originally defined in the CSS Grid Layout specification. In an effort to extend that feature of grid so that it applies to flexbox and columns as well, the grid-<\/code> prefix was dropped. It’s less specific to grid that way.<\/p>\n\n\n\n

But it’s also a bit of a hassle if you’ve already been using grid-row-gap<\/code> (as well as grid-gap<\/code> and grid-column-gap<\/code> for that matter) because it means we need to support the prefixed version until every browser makes the switch. The future-proof way to do that is to declare the prefixed property before<\/em> row-gap<\/code>. That way, browsers that support it will use it and those that don’t will go up the next level and get what they need.<\/p>\n\n\n\n

.something {\n  display: grid;\n  grid-template-rows: repeat(3, 1fr);\n  grid-row-gap: 2rem; \/* Will be used instead by browsers that do not support `row-gap` *\/\n  row-gap: 2rem; \/* Used by browsers that support `row-gap` *\/\n}<\/code><\/pre>\n\n\n

Syntax<\/h3>\n\n\n
row-gap: normal | <length-percentage><\/code><\/pre>\n\n\n\n
  • Initial value:<\/strong> normal<\/code><\/li>
  • Applies to:<\/strong> multi-column containers, flex containers, grid containers<\/li>
  • Inherited:<\/strong> no<\/li>
  • Percentages:<\/strong> refer to corresponding dimension of the content area<\/li>
  • Computed value:<\/strong> specified keyword, else a compute <length-percentage><\/code> value<\/li>
  • Animation type:<\/strong> by computed value type<\/li><\/ul>\n\n\n\n

    This syntax means that row-gap<\/code> accepts a normal<\/code> value (which is the default) or a specific length in units (e.g. 40px) or percentage (e.g. 5%).<\/p>\n\n\n

    Values<\/h3>\n\n\n

    Aside from the normal<\/code> value, row-gap<\/code> accepts numbers and percentages. “Normal” means whatever is standard for the browser.<\/p>\n\n\n\n

    \/* Default value *\/\nrow-gap: normal;\n\n\/* <length> values *\/\nrow-gap: 50px;\nrow-gap: 2rem;\nrow-gap: 1.5em;\nrow-gap: 5vw;\nrow-gap: 25ch;\n\n\/* <percentage> value *\/\nrow-gap: 15%;\n\n\/* Global values *\/\nrow-gap: inherit;\nrow-gap: initial;\nrow-gap: unset;<\/code><\/pre>\n\n\n

    Demo<\/h3>\n\n\n