Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
estelle authored Jun 18, 2024
1 parent a4c2c53 commit b117dc0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions files/en-us/web/css/gap/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ browser-compat: css.properties.gap

{{CSSRef}}

The **`gap`** [CSS](/en-US/docs/Web/CSS) [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties) sets the gaps ({{glossary("gutters")}}) between rows and columns. This property applies to [multi-column](/en-US/docs/Web/CSS/CSS_multicol_layout) containers, [flex](/en-US/docs/Web/CSS/CSS_flexible_box_layout) containers, and [grid]((/en-US/docs/Web/CSS/CSS_grid_layout) containers.
The **`gap`** [CSS](/en-US/docs/Web/CSS) [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties) sets the gaps (also called {{glossary("gutters")}}) between rows and columns. This property applies to [multi-column](/en-US/docs/Web/CSS/CSS_multicol_layout), [flex](/en-US/docs/Web/CSS/CSS_flexible_box_layout), and [grid](/en-US/docs/Web/CSS/CSS_grid_layout) containers.

{{EmbedInteractiveExample("pages/css/gap.html")}}

Expand Down Expand Up @@ -55,26 +55,30 @@ gap: unset;

### Values

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>`.
This property is specified as a value for `<'row-gap'>`, followed optionally by a value for `<'column-gap'>`. If `<'column-gap'>` is omitted, it is set to the same value as `<'row-gap'>`. Both `<'row-gap'>` and `<'column-gap'>` can be each specified as a `<length>` or a `<percentage>`.

- {{CSSxRef("&lt;length&gt;")}}
- : Is the width of the gutter separating the grid lines.
- : Specifies the width of the gutter separating the columns, {{glossary("flex item","flex items")}}, flex lines, and {{glossary("grid lines")}},.
- {{CSSxRef("&lt;percentage&gt;")}}
- : Is the width of the gutter separating the grid lines, relative to the dimension of the element.
- : Specifies the width of the gutter separating the columns, flex items, flex lines, and grid lines relative to the dimension of the element.

## Description

This property defines gaps between columns in CSS multi-column layout, flex items and flex lines in flexible box layout, and both rows and columns in CSS grid layout.
This property defines gaps between columns in [CSS multi-column layout](/en-US/docs/Web/CSS/CSS_multi-column_layout), flex items and flex lines in [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout), and both rows and columns in [CSS grid layout](/en-US/docs/Web/CSS/CSS_grid_layout).

The generated gaps create empty tracks the width or height of the gap's size. In multi-column containers, the first value is the gap is between CSS columns. In grid layout, the first value defines the gutter between rows and the second value sets the siz of the gutter between the column. If only one value is included, that value is used for both dimensions, in both grid and flex layouts.
The generated gaps create empty space the width or height of the gap's size.

In grid layout, the first value defines the gutter between rows and the second value sets the siz of the gutter between the column. In both grid and flex layouts, if only one value is included, that value is used for both dimensions.

With flex containers, whether the first value is the gap between flex items or between flex line depends on the direction. Flex items are laid out in either rows or columns depending on the value of the {{cssxref("flex-direction")}} property. With rows (`row` (the default) or `row-reverse`), the first value defines the gap between flex lines and the second value defines the gap between items within each line. With columns, (when `flex-direction` is set to `column` or `column-reverse`) the first value defines the gap between flex items within a flex line and the second value defines the gaps between each flex line.

The property resolves percentages against the size of the content box. When this size is definite, the behavior is well-defined and consistent across layout modes. As these three layout modes treat cyclic percentage sizes differently, `gap` does as well. In grid layout, cyclic percentage sizes resolve against zero for determining {{glossary("intrinsic size")}} contributions, but resolve against the box's content box when laying out the box's contents. In flex layout, cyclic percentage sizes always resolve against zero.
In multi-column containers, the first value is the gap in between CSS columns. A dividing line can be added to the otherwise "empty space" via the {{cssxref("column-rule-style")}} property or {{cssxref("column-rule")}} shorthand.

If the value is specified as a percentage, the property resolves the value relative to the size of the element's content box. When this size is definite, the behavior is well-defined and consistent across layout modes. As these three layout modes (multi-column, flex, and grid) treat cyclic percentage sizes differently, `gap` does so as well. In grid layout, cyclic percentage sizes resolve against zero for determining {{glossary("intrinsic size")}} contributions, but resolve against the box's content box when laying out the box's contents. In flex layout, cyclic percentage sizes always resolve against zero.

The visible space between elements may differ from the value of the `gap` property, as the margins, padding, and distributed alignment may increase the visible separation between boxes beyond what is specified in `gap`.
The visible space between elements may differ from the specified `gap` value because margins, padding, and distributed alignment may increase the separation between elements beyond what is specified by `gap`.

Early versions of the specification called this property `grid-gap`, and to maintain compatibility with legacy websites, browsers will still accept `grid-gap` as an alias for `gap`.
Early versions of the specification called this property `grid-gap`, and to maintain compatibility with legacy websites, browsers still accept `grid-gap` as an alias for `gap`.

## Formal definition

Expand Down Expand Up @@ -198,7 +202,7 @@ Early versions of the specification called this property `grid-gap`, and to main

- {{CSSxRef("row-gap")}}
- {{CSSxRef("column-gap")}}
- [Basic concepts of grid layout - Gutters](/en-US/docs/Web/CSS/CSS_grid_layout/Basic_concepts_of_grid_layout#gutters)
- [Basic concepts of grid layout: gutters](/en-US/docs/Web/CSS/CSS_grid_layout/Basic_concepts_of_grid_layout#gutters)
- [CSS box alignment](/en-US/docs/Web/CSS/CSS_box_alignment) module
- [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) module
- [CSS grid layout](/en-US/docs/Web/CSS/CSS_grid_layout) module
Expand Down

0 comments on commit b117dc0

Please sign in to comment.