Bootstrap5 Containers
In the previous chapter, we learned that Bootstrap requires a container element to wrap the content of the website.
We can use the following two container classes:
- .containerThe class is the default container, providing a fixed-width layout whose width adjusts with different screen sizes.
- .container-fluidThe class is used for 100% width, occupying the entire viewport (viewport) container. Using this container class will always fill the full screen width, suitable for full-screen layouts.

Fixed-width
.containerThe class is used to create fixed-width responsive pages.
Note:The width (max-width) will scale up or down proportionally according to the screen width.
| Super small screen <576px |
Small screen ≥576px |
Medium screen ≥768px |
Large screen ≥992px |
Extra large screen ≥1200px |
Super large screen ≥1400px |
|
|---|---|---|---|---|---|---|
| max-width | 100% | 540px | 720px | 960px | 1140px | 1320px |
In the following example, we can try adjusting the browser window size to see how the container width changes across different screens:
Bootstrap5 .container example
Try it »
Note:Super large screen (≥1400px) is newly added in Bootstrap 5. Bootstrap 4's largest was extra large screen (≥1200px).
100% width
.container-fluidThe class is used to create a full-screen size container. The container always spans the entire screen width (width is always 100%):
Bootstrap5 .container-fluid example
Try it »
Container padding
By default, containers have left and right padding, but no top or bottom padding. Bootstrap provides some spacing classes for padding and margins. For example,.pt-5is used to add top padding:
Container border and color
Bootstrap also provides some border classes and color classes (bg-dark, bg-primary, etc.) for styling containers:
Bootstrap5 example
Try it »
We will explain these styles in detail in later chapters.
Responsive containers
You can use the class to create responsive containers..container-sm|md|lg|xlThe container's max-width property value will change based on the screen size.
Extra small screen
| Class | Small screen <576px |
Medium screen ≥576px |
Large screen ≥768px |
Extra large screen ≥992px |
Super large screen ≥1200px |
Bootstrap5 example ≥1400px |
|---|---|---|---|---|---|---|
.container-sm |
100% | 540px | 720px | 960px | 1140px | 1320px |
.container-md |
100% | 100% | 720px | 960px | 1140px | 1320px |
.container-lg |
100% | 100% | 100% | 960px | 1140px | 1320px |
.container-xl |
100% | 100% | 100% | 100% | 1140px | 1320px |
.container-xxl |
100% | 100% | 100% | 100% | 100% | 1320px |
Bootstrap5 example
Other extensions