Bootstrap grid breakpoints


Bootstrap's grid breakpoints are a core feature that enables responsive web design by adjusting layouts based on different screen sizes. Here’s an in-depth explanation of what grid breakpoints are and how they work in Bootstrap.

What Are Grid Breakpoints?

Grid breakpoints are specific screen widths at which the layout of your grid elements (like columns) changes to optimize the presentation of content for different devices. These breakpoints allow you to control how content is displayed across various screen sizes, ensuring a responsive and user-friendly design.

Bootstrap’s Default Breakpoints


Bootstrap defines several breakpoints that are used to adjust the layout. Here are the default breakpoints for Bootstrap 5:

  1. Extra Small (xs): <576px

    • Description: This breakpoint applies to devices with a screen width smaller than 576px (e.g., smartphones in portrait mode). Columns stack vertically by default.
  2. Small (sm): ≥576px

    • Description: This breakpoint applies to devices with a screen width of 576px and up (e.g., smartphones in landscape mode and small tablets). Columns align horizontally when screen size is greater than or equal to 576px.
  3. Medium (md): ≥768px

    • Description: This breakpoint applies to devices with a screen width of 768px and up (e.g., tablets in landscape mode and small desktops). Columns can be arranged into more complex layouts.
  4. Large (lg): ≥992px

    • Description: This breakpoint applies to devices with a screen width of 992px and up (e.g., desktops and large tablets). Columns become more evenly distributed.
  5. Extra Large (xl): ≥1200px

    • Description: This breakpoint applies to devices with a screen width of 1200px and up (e.g., large desktops). Columns are arranged in a more expansive layout.
  6. Extra Extra Large (xxl): ≥1400px (added in Bootstrap 5)

    • Description: This breakpoint applies to devices with a screen width of 1400px and up (e.g., very large screens and high-resolution displays).

How Breakpoints Work

Bootstrap uses CSS media queries to apply styles at different screen widths. These media queries ensure that your layout adjusts according to the viewport size, providing a consistent user experience across various devices.

Example Media Queries:

/* Extra Small */ @media (max-width: 575.98px) { /* styles */ } /* Small */ @media (min-width: 576px) { /* styles */ } /* Medium */ @media (min-width: 768px) { /* styles */ } /* Large */ @media (min-width: 992px) { /* styles */ } /* Extra Large */ @media (min-width: 1200px) { /* styles */ } /* Extra Extra Large */ @media (min-width: 1400px) { /* styles */ }

Using Breakpoints in Bootstrap Layouts

Bootstrap’s grid system uses a 12-column layout that adapts based on these breakpoints. You can specify how many columns an element should span at different screen sizes using classes.

Example HTML Layout:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap Grid Breakpoints</title> <link href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-beta1/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <div class="row"> <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2"> <div class="p-3 mb-2 bg-primary text-white">Column 1</div> </div> <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2"> <div class="p-3 mb-2 bg-secondary text-white">Column 2</div> </div> <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2"> <div class="p-3 mb-2 bg-success text-white">Column 3</div> </div> <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2"> <div class="p-3 mb-2 bg-danger text-white">Column 4</div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-beta1/js/bootstrap.min.js"></script> </body> </html>

Explanation of the Example:

  • .col-12: Full width on extra small screens.
  • .col-sm-6: Half width on small screens (576px and up).
  • .col-md-4: One-third width on medium screens (768px and up).
  • .col-lg-3: One-fourth width on large screens (992px and up).
  • .col-xl-2: One-sixth width on extra large screens (1200px and up).