Loading lessons...
Containers
Containers
Containers are the most basic layout element in Bootstrap. They are required when using the default grid system. A container centers your content and provides horizontal padding (gutters).
The three container classes
| Class | Behavior |
|---|---|
.container | Responsive, fixed-width container with breakpoints |
.container-fluid | Full-width, spans the entire viewport |
.container-{breakpoint} | Full width until a breakpoint, then fixed width |
Example: fixed width container
<div class="container">
<h1>My First Bootstrap Page</h1>
<p>This content is centered with padding.</p>
</div>
Example: full width container
<div class="container-fluid">
<h1>Full Width</h1>
<p>This stretches across the whole screen.</p>
</div>
Breakpoint variants
<div class="container-sm">sm</div>
<div class="container-md">md</div>
<div class="container-lg">lg</div>
<div class="container-xl">xl</div>
<div class="container-xxl">xxl</div>
These containers are full width until the specified breakpoint is reached, then they become fixed width.
Breakpoint sizes
| Breakpoint | Class infix | Dimensions |
|---|---|---|
| Extra small | (none) | < 576px |
| Small | sm | >= 576px |
| Medium | md | >= 768px |
| Large | lg | >= 992px |
| Extra large | xl | >= 1200px |
| Extra extra large | xxl | >= 1400px |
TL;DR
.containercenters content with a responsive width..container-fluidspans the full viewport width..container-{breakpoint}is full width until a breakpoint.- Containers provide horizontal padding (gutters).