✦ A decade of Canvas craft, now driven by AI — describe it, watch it build live.Start building
Glossary

What Is Bootstrap 5 Grid System?

The Bootstrap 5 Grid System is a responsive, mobile-first layout framework built on CSS Flexbox that divides a page into 12 equal columns across six breakpoint tiers (xs, sm, md, lg, xl, xxl). It uses a container-row-column hierarchy where columns are sized using predefined classes like `col-md-6` or `col-lg-4`, and automatically reflow at specified viewport widths defined in Bootstrap's Sass variable map. Unlike its Bootstrap 4 predecessor, version 5 removes the jQuery dependency entirely and introduces a new `xxl` breakpoint at 1400px.

What Is Bootstrap 5 Grid System?

The Bootstrap 5 Grid System is a responsive, mobile-first layout framework built on CSS Flexbox that divides a page into 12 equal columns across six breakpoint tiers (xs, sm, md, lg, xl, xxl). It uses a container-row-column hierarchy where columns are sized using predefined classes like `col-md-6` or `col-lg-4`, and automatically reflow at specified viewport widths defined in Bootstrap's Sass variable map. Unlike its Bootstrap 4 predecessor, version 5 removes the jQuery dependency entirely and introduces a new `xxl` breakpoint at 1400px.

How Bootstrap 5 Grid System Works

The grid is anchored by three structural layers: containers, rows, and columns. Containers (`container`, `container-fluid`, or responsive container variants like `container-md`) establish the horizontal max-width and horizontal padding (called gutters). A `container` has fixed max-widths at each breakpoint — for example, 960px at `md` and 1140px at `lg` — while `container-fluid` spans 100% of the viewport at all times. Rows use `display: flex` with `flex-wrap: wrap` and negative horizontal margins to counteract the column padding, ensuring proper edge alignment. Columns are flex children that use `flex: 0 0 auto` with a calculated `width` percentage. A `col-md-6` class computes to `width: 50%` because 6 out of 12 columns equals 50%. Bootstrap generates these widths via Sass loops, so the math is consistent and predictable. When no column width class is specified (just `col`), Bootstrap distributes remaining space equally among all auto-width columns using `flex: 1 0 0%`. This makes auto-layout columns particularly useful for equal-width distributions without hardcoding sizes. Breakpoints are defined as min-width media queries in Bootstrap's `_variables.scss`: `sm` starts at 576px, `md` at 768px, `lg` at 992px, `xl` at 1200px, and `xxl` at 1400px. Because Bootstrap is mobile-first, a class like `col-md-8` applies from 768px and up — below that breakpoint, the column defaults to full width (`width: 100%`). This cascade means you only need to define a layout at the point where it changes, reducing the total number of classes needed. Gutters in Bootstrap 5 were redesigned from Bootstrap 4's fixed padding to a CSS custom property system using `--bs-gutter-x` and `--bs-gutter-y`. Gutter utility classes (`g-0` through `g-5`, or axis-specific `gx-*` and `gy-*`) dynamically set these custom properties, which are then consumed by the row and column CSS rules. This approach allows runtime gutter adjustments without Sass recompilation and enables vertical gutters — a significant gap from Bootstrap 4, which had no native vertical gutter control.

Best Practices for Bootstrap 5 Grid System

Always start with mobile column classes and layer larger breakpoints on top — for example, `col-12 col-md-6 col-lg-4` gives you a stacked single column on phones, a two-column layout on tablets, and a three-column layout on desktops. Avoid nesting rows more than two levels deep; each nested row resets the 12-column count within its parent column, which can produce unexpected layouts and makes the DOM unnecessarily deep. Use `col` (auto-width) for equal-width columns rather than explicitly writing `col-6 col-6`, which becomes brittle if you add a third column later. Leverage `offset-*` classes sparingly — if you find yourself using many offsets to center content, consider switching to Bootstrap's `justify-content-center` on the row with auto-width columns, which is more semantically correct and easier to maintain. Use responsive gutter classes (`gx-2 gx-md-4`) rather than adding manual padding to columns, since manual padding breaks the grid's internal margin compensation and causes alignment drift at container edges.

Bootstrap 5 Grid System & Canvas Builder

CanvasBuilder generates HTML using the Canvas template, which is built on Bootstrap 5, so every layout section it produces — hero blocks, feature grids, pricing tables, footers — uses proper Bootstrap 5 grid markup with responsive column classes, semantic container structures, and gutter utilities rather than inline styles or custom CSS hacks. This means the output is immediately editable by any developer who knows Bootstrap 5, and the responsive behavior works out of the box without additional CSS. The clean, standards-compliant HTML output also ensures compatibility with Bootstrap 5 component upgrades and makes it straightforward to integrate the generated code into existing Bootstrap-based projects.

Try Canvas Builder →

Frequently Asked Questions

What is the difference between `col`, `col-auto`, and `col-{n}` in Bootstrap 5?
`col` creates an equal-width column that grows to fill available space using `flex: 1 0 0%`, so all `col` siblings divide the row width equally regardless of content. `col-auto` sizes the column based on its natural content width using `width: auto` and `flex: 0 0 auto`, making it useful for things like buttons or labels that should only take the space they need. `col-{n}` (e.g., `col-8`) sets an explicit fractional width — `n/12 * 100%` — and is the right choice when a column must occupy a specific proportion of the layout regardless of sibling count.
How do Bootstrap 5 gutters differ from Bootstrap 4 gutters, and why does it matter?
Bootstrap 4 used fixed `padding-left` and `padding-right` on columns (15px each) with matching negative margins on rows, and had no native vertical gutter support. Bootstrap 5 replaced this with CSS custom properties (`--bs-gutter-x` and `--bs-gutter-y`), allowing gutters to be changed at runtime via utility classes like `gx-3` or `gy-2` without touching Sass. This matters because vertical gutters are now grid-native — previously developers added `margin-bottom` manually to simulate them, which caused inconsistent spacing when columns wrapped onto multiple rows.
How does CanvasBuilder use the Bootstrap 5 grid system in the HTML it generates?
CanvasBuilder outputs production-ready HTML built on the Canvas HTML template, which uses Bootstrap 5's grid system as its layout foundation. The AI generates semantically correct container-row-column structures with appropriate responsive breakpoint classes rather than hardcoded widths or inline styles, meaning the exported HTML is immediately customizable and behaves correctly across all device sizes. This also means any developer receiving CanvasBuilder's output can extend or modify the layout using standard Bootstrap 5 documentation without needing to reverse-engineer proprietary markup.