A container is the outer box that holds and centres your page content. Every Bootstrap layout starts with one.
Types
| Class | Width |
|---|---|
.container |
fixed max-width that changes at each breakpoint, centred |
.container-fluid |
always 100% of the screen width |
.container-sm / -md / -lg / -xl / -xxl |
100% wide until that breakpoint, then fixed |
Max widths of .container
| Screen | Breakpoint | Max width |
|---|---|---|
| Extra small | < 576px | 100% |
| sm | ≥ 576px | 540px |
| md | ≥ 768px | 720px |
| lg | ≥ 992px | 960px |
| xl | ≥ 1200px | 1140px |
| xxl | ≥ 1400px | 1320px |
Containers also add a little padding on the left and right, so text never touches the screen edge.
Example
Example — container vs container-fluid
HTML
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container bg-primary text-white p-3 my-2">.container – fixed width, centred</div>
<div class="container-fluid bg-success text-white p-3 my-2">.container-fluid – full width</div>
<div class="container-md bg-warning p-3 my-2">.container-md – full width below 768px</div>
Resize the preview to see how each container changes width.
Try it Now »