What are gutters in Bootstrap?

Bootstrap 4 is a free HTML, CSS, and JavaScript framework which enables programmers to create responsive, mobile-first websites. It includes design templates for typography, forms, buttons, navigation, and other interface elements that are based on CSS and (optionally) JavaScript.

The Bootstrap grid system prioritizes mobile-first design and is responsive. Classes in bootstrap let us specify how much space there should be between the content and the column.

Gutters in bootstrap

In a bootstrap grid, gutters are the intervals between columns. They are the voids between the components. They are positioned so that each column has an additional 30 pixels on both sides. Gutters are the padding between columns, used to space responsively and align content in the bootstrap grid system.

Gutters are created by horizontal padding when padding-left and padding-right are being set on each column and the negative margin is set to offset that at the start and the end of each row to align content. Gutters can be responsibly adjusted using specific to modify the gutters.

Types of gutters

Horizontal gutters

Horizontal gutter widths are controlled by the gx- classes adjusting the container or the container-fluid parents if larger gutters are used to avoid unwanted overflow. An example is shown below.

Explanation

  • Lines 6–8: A container is created with a row class controlled by horizontal classes gx-5 thereby adjusting the container.

  • Lines 8–12: Two columns are created. Each with a padding of 3 and a background color light , aligned with the text custom column padding.

Vertical gutters

The gx- classes can also be used to control the vertical gutter widths. The vertical gutters can also cause some overflow below the row at the end of the page. An example is shown below.

Explanation

  • Lines 6–7: A container class is created with a hidden overflow and a row controlled by vertical gutter widths gy-5.

  • Lines 8-21: Four-column classes are created and padded with a background image light and the text custom column padding.

Row-column gutters

Gutters can also be added to row columns by using responsive row columns and responsive gutter classes. An example is shown below.

Code explanation

  • Lines 6–7: A container is being created with a row-column and responsive gutter classes g-2 and g-lg-3.

  • Lines 8–39: 10-column classes are padded and styled with the background colour light with the text Row-column.

Free Resources