Grids

Grid system uses a series of containers, rows, and columns to layout and align content. It's built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.
New to or unfamiliar with flexbox? Read this CSS Tricks flexbox guide for background, terminology, guidelines, and code snippets.

One of three columns
One of three columns
One of three columns

This example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent .container.

Breaking it down, here's how it works:

  • Containers provide a means to center and horizontally pad your site's contents. Use .container for a responsive pixel width or .container-fluid for width: 100% across all viewport and device sizes.
  • Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
  • In a grid layout, content must be placed within columns and only columns may be immediate children of rows.
  • Thanks to flexbox, grid columns without a specified width will automatically layout as equal width columns. For example, four instances of .col-sm will each automatically be 25% wide from the small breakpoint and up. See the auto-layout columns section for more examples.
  • Column classes indicate the number of columns you'd like to use out of the possible 12 per row. So, if you want three equal-width columns across, you can use .col-4.
  • Column widths are set in percentages, so they're always fluid and sized relative to their parent element.
  • Columns have horizontal padding to create the gutters between individual columns, however, you can remove the margin from rows and padding from columns with .no-gutters on the .row.
  • To make the grid responsive, there are seven grid breakpoints, one for each responsive breakpoint: extra extra small, extra small, small, medium, large, extra large, and extra extra large.
  • Grid breakpoints are based on minimum width media queries, meaning they apply to that one breakpoint and all those above it (e.g., .col-sm-4 applies to small, medium, large, and extra large devices, but not the first xs breakpoint).
  • You can use predefined grid classes (like .col-4)

See how aspects of the grid system work across multiple devices:

XXS
<550px
XS
≥550px
S
≥769px
M
≥992px
L
≥1280px
XL
≥1440px
XXL
≥1680px
Max container width 100% 90% 90% 90% 1248px 1408px 1648px
Class prefix .col- .col-xs- .col-sm- .col-md- .col-lg- .col-xl- .col-xxl-
# of columns 12
Gutter width 32px (16px on each side of a column)
Nestable Yes
Column ordering Yes

Additional examples

The following examples are also used by our Playwright CSS property assertion tests.

Use numbered column classes like .col-sm-8 and .col-sm-4 to create columns of specific widths within a .container.

col-sm-8
col-sm-4

Fluid container

Use .container-fluid for a full-width container, spanning the entire width of the viewport.

Column in fluid container
Column in fluid container
Column in fluid container

No gutters

Remove the horizontal padding from columns and the negative margin from rows with .no-gutters.

No gutters — half width
No gutters — half width

Column widths

Columns use percentage-based widths. A 12-column grid means .col-sm-6 is 50%, .col-sm-4 is 33.33%, and so on.

col-sm-6
col-sm-6
col-sm-4
col-sm-4
col-sm-4
col-sm-3
col-sm-3
col-sm-3
col-sm-3
col-sm-12