2020-04-02 20:44:07 +02:00
---
layout: docs
title: Breakpoints
2021-01-09 22:06:41 +01:00
description: Breakpoints are customizable widths that determine how your responsive layout behaves across device or viewport sizes in Bootstrap.
2020-04-02 20:44:07 +02:00
group: layout
2021-08-04 17:41:51 +02:00
aliases: "/docs/5.1/layout/"
2020-04-02 20:44:07 +02:00
toc: true
---
## Core concepts
- **Breakpoints are the building blocks of responsive design.** Use them to control when your layout can be adapted at a particular viewport or device size.
- **Use media queries to architect your CSS by breakpoint.** Media queries are a feature of CSS that allow you to conditionally apply styles based on a set of browser and operating system parameters. We most commonly use `min-width` in our media queries.
- **Mobile first, responsive design is the goal.** Bootstrap's CSS aims to apply the bare minimum of styles to make a layout work at the smallest breakpoint, and then layers on styles to adjust that design for larger devices. This optimizes your CSS, improves rendering time, and provides a great experience for your visitors.
## Available breakpoints
Bootstrap includes six default breakpoints, sometimes referred to as _grid tiers_ , for building responsively. These breakpoints can be customized if you're using our source Sass files.
< table class = "table" >
< thead >
< tr >
< th > Breakpoint< / th >
< th > Class infix< / th >
< th > Dimensions< / th >
< / tr >
< / thead >
< tbody >
< tr >
2022-01-27 10:58:59 +01:00
< td > Extra small< / td >
2020-04-02 20:44:07 +02:00
< td > < em > None< / em > < / td >
2020-08-05 09:56:00 +02:00
< td > < 576px< / td >
2020-04-02 20:44:07 +02:00
< / tr >
< tr >
< td > Small< / td >
< td > < code > sm< / code > < / td >
< td > ≥ 576px< / td >
< / tr >
< tr >
< td > Medium< / td >
< td > < code > md< / code > < / td >
< td > ≥ 768px< / td >
< / tr >
< tr >
< td > Large< / td >
< td > < code > lg< / code > < / td >
< td > ≥ 992px< / td >
< / tr >
< tr >
< td > Extra large< / td >
< td > < code > xl< / code > < / td >
< td > ≥ 1200px< / td >
< / tr >
< tr >
< td > Extra extra large< / td >
< td > < code > xxl< / code > < / td >
< td > ≥ 1400px< / td >
< / tr >
< / tbody >
< / table >
2020-07-31 21:38:17 +02:00
Each breakpoint was chosen to comfortably hold containers whose widths are multiples of 12. Breakpoints are also representative of a subset of common device sizes and viewport dimensions—they don't specifically target every use case or device. Instead, the ranges provide a strong and consistent foundation to build on for nearly any device.
2020-04-02 20:44:07 +02:00
These breakpoints are customizable via Sass—you'll find them in a Sass map in our `_variables.scss` stylesheet.
2020-04-13 23:40:47 +02:00
{{< scss-docs name = "grid-breakpoints" file = "scss/_variables.scss" > }}
2020-04-02 20:44:07 +02:00
For more information and examples on how to modify our Sass maps and variables, please refer to [the Sass section of the Grid documentation ]({{< docsref "/layout/grid#sass" >}} ).
## Media queries
Since Bootstrap is developed to be mobile first, we use a handful of [media queries ](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries ) to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.
### Min-width
Bootstrap primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.
2020-10-19 11:56:49 +02:00
```scss
2020-04-02 20:44:07 +02:00
// Source mixins
// No media query necessary for xs breakpoint as it's effectively `@media (min-width: 0) { ... }`
@include media-breakpoint-up(sm) { ... }
@include media-breakpoint-up(md) { ... }
@include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(xl) { ... }
@include media-breakpoint-up(xxl) { ... }
// Usage
// Example: Hide starting at `min-width: 0` , and then show at the `sm` breakpoint
.custom-class {
display: none;
}
@include media-breakpoint-up(sm) {
.custom-class {
display: block;
}
}
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
These Sass mixins translate in our compiled CSS using the values declared in our Sass variables. For example:
2020-10-19 11:56:49 +02:00
```scss
2020-04-02 20:44:07 +02:00
// X-Small devices (portrait phones, less than 576px)
// No media query for `xs` since this is the default in Bootstrap
// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }
// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }
// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }
// X-Large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }
// XX-Large devices (larger desktops, 1400px and up)
@media (min-width: 1400px) { ... }
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
### Max-width
We occasionally use media queries that go in the other direction (the given screen size *or smaller* ):
2020-10-19 11:56:49 +02:00
```scss
2020-04-18 13:02:26 +02:00
// No media query necessary for xs breakpoint as it's effectively `@media (max-width: 0) { ... }`
2020-04-02 20:44:07 +02:00
@include media-breakpoint-down(sm) { ... }
@include media-breakpoint-down(md) { ... }
@include media-breakpoint-down(lg) { ... }
@include media-breakpoint-down(xl) { ... }
2020-04-18 13:02:26 +02:00
@include media-breakpoint-down(xxl) { ... }
2020-04-02 20:44:07 +02:00
// Example: Style from medium breakpoint and down
@include media-breakpoint-down(md) {
.custom-class {
display: block;
}
}
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
These mixins take those declared breakpoints, subtract `.02px` from them, and use them as our `max-width` values. For example:
2020-10-19 11:56:49 +02:00
```scss
2021-08-03 18:08:10 +02:00
// `xs` returns only a ruleset and no media query
// ... { ... }
// `sm` applies to x-small devices (portrait phones, less than 576px)
2020-04-02 20:44:07 +02:00
@media (max-width: 575.98px) { ... }
2021-08-03 18:08:10 +02:00
// `md` applies to small devices (landscape phones, less than 768px)
2020-04-02 20:44:07 +02:00
@media (max-width: 767.98px) { ... }
2021-08-03 18:08:10 +02:00
// `lg` applies to medium devices (tablets, less than 992px)
2020-04-02 20:44:07 +02:00
@media (max-width: 991.98px) { ... }
2021-08-03 18:08:10 +02:00
// `xl` applies to large devices (desktops, less than 1200px)
2020-04-02 20:44:07 +02:00
@media (max-width: 1199.98px) { ... }
2021-08-03 18:08:10 +02:00
// `xxl` applies to x-large devices (large desktops, less than 1400px)
2020-04-02 20:44:07 +02:00
@media (max-width: 1399.98px) { ... }
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
2020-10-13 15:37:21 +02:00
{{< callout warning > }}
2020-04-02 20:44:07 +02:00
{{< partial " callout-info-mediaqueries-breakpoints . md " > }}
2020-10-13 15:37:21 +02:00
{{< / callout > }}
2020-04-02 20:44:07 +02:00
### Single breakpoint
There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths.
2020-10-19 11:56:49 +02:00
```scss
2020-04-02 20:44:07 +02:00
@include media-breakpoint-only(xs) { ... }
@include media-breakpoint-only(sm) { ... }
@include media-breakpoint-only(md) { ... }
@include media-breakpoint-only(lg) { ... }
@include media-breakpoint-only(xl) { ... }
@include media-breakpoint-only(xxl) { ... }
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
2020-04-18 13:02:26 +02:00
For example the `@include media-breakpoint-only(md) { ... }` will result in :
2020-04-02 20:44:07 +02:00
2020-10-19 11:56:49 +02:00
```scss
2020-04-18 13:02:26 +02:00
@media (min-width: 768px) and (max-width: 991.98px) { ... }
2020-10-19 11:56:49 +02:00
```
2020-04-02 20:44:07 +02:00
### Between breakpoints
2020-04-18 13:02:26 +02:00
Similarly, media queries may span multiple breakpoint widths:
2020-04-02 20:44:07 +02:00
2020-10-19 11:56:49 +02:00
```scss
2020-04-02 20:44:07 +02:00
@include media-breakpoint-between(md, xl) { ... }
2020-10-19 11:56:49 +02:00
```
2020-04-18 13:02:26 +02:00
Which results in:
2020-10-19 11:56:49 +02:00
```scss
2020-04-18 13:02:26 +02:00
// Example
// Apply styles starting from medium devices and up to extra large devices
@media (min-width: 768px) and (max-width: 1199.98px) { ... }
2020-10-19 11:56:49 +02:00
```