agyanadda@gmail.com

Bootstrap Containers

Bootstrap Basics 1 min read Updated Dec 1, 2026 Topic 3 of 32

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 »

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which class makes a container always 100% wide?

Exercise 2 True / False

.container is centred on the page.

Exercise 3 Fill in the Blank

The largest Bootstrap 5 breakpoint is called ___.

Frequently Asked Questions

You should not. Nested containers add extra padding. Use one container and build inside it with rows and columns.