# gap property

The `gap` property specifies a distance between elements in a grid. In the property value of the parent element, we indicate the gap we need with the measurement units - `px`, `%`, etc.

## Syntax

`selector { gap: distance; }`

## Example

Let's set the gap between elements in a grid:

`<div id="parent"> <div id="elem1">1</div> <div id="elem2">2</div> <div id="elem3">3</div> </div>` `#parent { display: grid; grid-template-areas: 'third second first'; border: 2px solid #696989; padding: 10px; gap: 10px; } #parent > div { padding: 10px; border: 1px solid #696989; } #elem1 { grid-area: first; } #elem2 { grid-area: second; } #elem3 { grid-area: third; }`

:

## Example

Now let's set the gap between elements in the grid in `%`:

`<div id="parent"> <div id="elem1">1</div> <div id="elem2">2</div> <div id="elem3">3</div> </div>` `#parent { display: grid; grid-template-areas: 'third second first'; border: 2px solid #696989; padding: 10px; gap: 2.5%; } #parent > div { padding: 10px; border: 1px solid #696989; } #elem1 { grid-area: first; } #elem2 { grid-area: second; } #elem3 { grid-area: third; }`

:

## See also

- the `row-gap` property
  that specifies a gap between rows in a grid
- the `column-gap` property
  that specifies a gap between columns in a grid

← →
↑
en ru