How many columns are in Bootstrap?
You can use a maximum of 12 columns in a Bootstrap grid system.
Bootstrap’s 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 explanation for how the grid system comes together.
<div class="container"> <div class="row"> <div class="col-md"> One of three columns </div> <div class="col-md"> One of three columns </div> <div class="col-md"> One of three columns </div> </div> </div>
The above example creates three equal-width columns across all devices and viewports using our
predefined grid classes. Those columns are centered in the page with the parent
Taking it step by step:
Bootstrap requires a containing element to wrap site contents and house our grid system. Without a container, the grid won't work properly.
Rows create horizontal groups of columns. Therefore, if you want to split your layout
Bootstrap's grid system allows up to 12 columns across the page.
.col-md-* to create a column , where
the number of columns between 1 and 12.
md specifies the breakpoint where the columns change its width.
md means "screen ≥768px", so I'm the example below the columns will stretch to
100% of the width on the screens smaller or equal 768px.
How it works
Breaking it down, here’s how the grid system comes together:
Our grid supports six responsive breakpoints. Breakpoints are based on
min-widthmedia queries, meaning they affect that breakpoint and all those above it (e.g.,
xxl). This means you can control container and column sizing and behavior by each breakpoint.
Containers center and horizontally pad your content. Use
.containerfor a responsive pixel width,
width: 100%across all viewports and devices, or a responsive container (e.g.,
.container-md) fir combination of fluid and pixel widths.
Rows are wrappers for columns. Each column has horizontal
padding(called a gutter) for controlling the space between them. This
paddingis then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. Rows also support modifier classes to uniformly apply column sizing and gutter classes to change the spacing of your content.
Columns are incredibly flexible. There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns. Column classes indicate the number of template columns to span (e.g.,
widths are set in percentages so you always have the same relative sizing.
Gutters are also responsive and customizable. Gutter classes are available across all breakpoints, with all the same sizes as our margin and padding spacing. Change horizontal gutters with
.gx-*classes, verical gutters with
.gy-*, or all gutters with
.g-0is also availble to remove gutters.
Sass variables, maps, and mixins power the grid. If you don’t want to use the predefined grid classes in Bootstrap, you can use our grid’s source Sass to create your own with more semantic markup. We also include some CSS custom properties to consume these Sass variables for even greater flexibility for you.