Bootstrap is a front-end framework that facilitates the creation of responsive web designs. It's used with HTML and CSS to provide various layout components such as typography, forms, and buttons.
Note: To know more about Bootstrap and how to use it, please refer to the following links:
To wrap a page content with Bootstrap, we use the .container
class. Containers are used to pad and align the content of a webpage. There are three different types of containers used in Bootstrap:
container
container-fluid
container-{breakpoint}
container
classThis is the default container class and sets a max-width
at each breakpoint to create a fix-width container.
Note: Breakpoints are customizable widths that dictate the behavior of a responsive webpage across different screen sizes.
<div class = "container">...</div>
The code below demonstrates how the container
class can be used to wrap page content:
container
classto the div
tag.h1
tag in the container
class. container-fluid
classThis container spans the entire width of the screen. To learn more about this class, please refer to this link.
<div class = "container-fluid">...</div>
container-{breakpoint}
classThis container is full-width until a specified breakpoint is reached, after which the max-width
will change to a higher breakpoint.
There are five types of breakpoints:
container-sm
: The container is 100% wide until the small breakpoint is reached.container-md
: The container is 100% wide until the medium breakpoint is reached.container-lg
: The container is 100% wide until the large breakpoint is reached.container-xl
: The container is 100% wide until the extra-large breakpoint is reached.container-xxl
: The container is 100% wide until the extra-extra-large breakpoint is reached.<div class = "container-sm">...</div>
Any of the other responsive containers can replace the container-sm
class in the syntax above.
max-width
comparisonsThe table below shows how the max-width
of each container compares with the other:
Container class | Extra small < 576px | Small ≥576px | Medium ≥768px | Large ≥992px | X-Large ≥1200px | XX-Large ≥1400px |
container | 100% | 540px | 720px | 960px | 1140px | 1320px |
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 |
container-fluid | 100% | 100% | 100% | 100% | 100% | 100% |
Free Resources