For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/css/properties/gap.md.
Lynx
  • English
  • gap

    Introduction

    The gap CSS shorthand property sets the gaps (gutters) between rows and columns in flexible box layout and grid layout.

    This property is a shorthand for the following CSS properties: row-gap and column-gap, this property is specified as a value for row-gap followed optionally by a value for column-gap. If column-gap is omitted, it's set to the same value as row-gap. row-gap and column-gap are each specified as a <length> or a <percentage>.

    Examples

    Syntax

    /* One <length> value */
    gap: 20px;
    gap: 1em;
    
    /* One <percentage> value */
    gap: 16%;
    gap: 100%;
    
    /* Two <length> values */
    gap: 20px 10px;
    gap: 1em 0.5em;
    
    /* One or two <percentage> values */
    gap: 16% 100%;
    gap: 21px 82%;
    
    /* calc() values */
    gap: calc(10% + 20px);
    gap: calc(20px + 10%) calc(10% - 5px);

    Values

    • <length>

      <length> is the width of the gutter in flexible box layout or grid layout.

    • <percentage>

      <percentage> is the width of the gutter separating the lines, relative to the dimension of the element.

    Formal definition

    Initial valueas each of the properties of the shorthand:
    • row-gap: 0
    • column-gap: 0
    Applies toflex containers, grid containers
    Inheritedno
    Animatable
    Percentagesrefer to corresponding dimension of the content area(e.g.,row-gap refer to column axis size)

    Formal syntax

    gap =
      <'row-gap'> <'column-gap'>?
    
    <row-gap> = <length-percentage [0,∞]>
    
    <column-gap> = <length-percentage [0,∞]>
    
    <length-percentage> =
      <length>      |
      <percentage>

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.