Bootstrap Containers


In this tutorial you will learn how to create containers with Bootstrap.

Creating Containers with Bootstrap

Containers are the most basic layout element in Bootstrap and are required when using the grid system. Containers are basically used to wrap content with some padding. They are also used to align the content horizontally center on the page in case of fixed width layout.

Bootstrap provides three different types containers:

  • .container, which has a max-width at each responsive breakpoint.
  • .container-fluid, which has 100% width at all breakpoints.
  • .container-{breakpoint}, which has 100% width until the specified breakpoint.

The table below illustrates how each container’s max-width changes across each breakpoint.

For example, when using the .container class the actual width of the container will be 100% if the viewport width is <576px, 540px if the viewport width is ≥576px but <768px, 720px if the viewport width is ≥768px but <992px, 960px if the viewport width is ≥992px but <1200px, 1140px if the viewport width is ≥1200px but <1400px, and 1320px if the viewport width is ≥1400px.

Similarly, when you use the .container-lg class the actual width of the container will be 100% until the viewport width is <992px, 960px if the viewport width is ≥992px but <1200px, 1140px if the viewport width ≥1200px but <1400px, and 1320px if the viewport width is ≥1400px.

ClassesBootstrap  Grid SystemX-Small<576pxSmall≥576pxMedium≥768pxLarge≥992pxX-Large≥1200pxXX-Large≥1400px
.container100%540px720px960px1140px1320px
.container-sm100%540px720px960px1140px1320px
.container-md100%100%720px960px1140px1320px
.container-lg100%100%100%960px1140px1320px
.container-xl100%100%100%100%1140px1320px
.container-xxl100%100%100%100%100%1320px
.container-fluid100%100%100%100%100%100%

Leave a Reply

Your email address will not be published. Required fields are marked *