Mastering Bootstrap CSS Media Queries

Ruth Jul 09, 2026

Bootstrap, a popular CSS framework, offers a robust system of media queries to help create responsive designs. Media queries allow us to apply styles based on the characteristics of the device rendering the content, such as its screen size, resolution, or orientation. In this article, we'll delve into the world of Bootstrap CSS media queries, exploring their syntax, usage, and best practices.

Bootstrap Media Queries and How to use it?
Bootstrap Media Queries and How to use it?

Before we dive in, let's ensure we have the basics covered. Bootstrap uses a mobile-first approach, meaning that styles for smaller screens are applied first, and then overridden for larger screens using media queries. This approach is not only efficient but also aligns with the way users interact with content on different devices.

Difference Between Bootstrap and CSS
Difference Between Bootstrap and CSS

Understanding Bootstrap's Media Query Syntax

Bootstrap's media queries follow the standard CSS media query syntax. They consist of a media type and one or more media queries separated by commas. The media type is typically 'screen' for devices with screens, but other types like 'print' are also possible. Here's a basic example:

an image of a computer screen with the text css media queries simple explanation
an image of a computer screen with the text css media queries simple explanation

```css @media (min-width: 768px) { /* Styles for screens wider than 768px */ } ```

Media Query Breakpoints

the words bootstrap 3 are written in white on a purple background with vertical stripes
the words bootstrap 3 are written in white on a purple background with vertical stripes

Bootstrap defines several preprocessors for common screen sizes, known as breakpoints. These breakpoints are used to create media queries and are defined in variables at the top of Bootstrap's CSS. The default breakpoints are:

  • $xs: Extra small devices (landscape phones, less than 576px)
  • $sm: Small devices (portrait phones, greater than 576px)
  • $md: Medium devices (tablets, greater than 768px)
  • $lg: Large devices (desktops, greater than 992px)
  • $xl: Extra large devices (large desktops, greater than 1200px)

You can use these breakpoints in your media queries like this:

Bootstrap 5.3 (2025) Cheat Sheet
Bootstrap 5.3 (2025) Cheat Sheet

```css @media (min-width: $lg) { /* Styles for screens wider than 992px */ } ```

Responsive Utilities

Bootstrap also provides responsive utilities that use media queries to apply styles based on the screen size. These utilities are classes that you can add to your HTML elements. For example, the class .d-none hides an element on small screens, while .d-sm-block shows it on small screens and up. Here's how you might use them:

a screenshot of a computer screen with the text,'how do i use this?
a screenshot of a computer screen with the text,'how do i use this?

```html

This content will be hidden on small screens but shown on medium screens and up.
```

Using Media Queries for Responsive Design

40+ Best Free Bootstrap Templates & Themes in 2026 — Speckyboy
40+ Best Free Bootstrap Templates & Themes in 2026 — Speckyboy
Responsive design with media query : screen size?
Responsive design with media query : screen size?
Bootstrap 5 Website Layout Design
Bootstrap 5 Website Layout Design
Bootstrap 3 grid system explained
Bootstrap 3 grid system explained
Breadcrumb using Bootstrap 5 #shorts #coding
Breadcrumb using Bootstrap 5 #shorts #coding
Introduction to CSS Media Queries | HTML Goodies
Introduction to CSS Media Queries | HTML Goodies
Welcome to SiteRaw
Welcome to SiteRaw
Complete Beginner CSS Master Notes
Complete Beginner CSS Master Notes
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
an info sheet showing the cost of mobile phones and their price ranges for each phone
an info sheet showing the cost of mobile phones and their price ranges for each phone
the screenshoter is showing how to use an app
the screenshoter is showing how to use an app
How to Use CSS Media Queries
How to Use CSS Media Queries
an image of a web page with the words'body'and'reader '
an image of a web page with the words'body'and'reader '
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Photo Gallery
Bootstrap Photo Gallery
CSS Notes for Beginners (Easy + Quick Guide) 🎨
CSS Notes for Beginners (Easy + Quick Guide) 🎨
How to create responsive website | How to create Media Query | Mobile responsive website
How to create responsive website | How to create Media Query | Mobile responsive website
Create Responsive Layout using Bootstrap | Bootstrap Media Query Explained With Example in Hindi
Create Responsive Layout using Bootstrap | Bootstrap Media Query Explained With Example in Hindi
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
What Are the Pros and Cons of Using Bootstrap in Web Development?
What Are the Pros and Cons of Using Bootstrap in Web Development?

Media queries are essential for creating responsive designs. They allow us to adjust the layout, typography, and other aspects of our design to suit different screen sizes. Here are a few examples:

```css /* Change the font size for larger screens */ @media (min-width: $lg) { body { font-size: 18px; } } /* Change the layout for larger screens */ @media (min-width: $lg) { .row { flex-direction: row-reverse; } } ```

Responsive Images

Media queries can also be used to serve different image sources based on the screen size. This can help improve performance by serving smaller images to smaller screens. Here's an example using the srcset attribute:

```html Description ```

Responsive Embeds

When embedding content like videos or iframes, the aspect ratio can change based on the screen size. Media queries can be used to adjust the height and width of the embed to maintain the aspect ratio. Here's an example:

```css iframe { width: 100%; aspect-ratio: auto 4 / 3; } @media (min-width: $lg) { iframe { width: 85%; } } ```

In the world of responsive design, media queries are a powerful tool. They allow us to create designs that adapt to the screen size, providing a better user experience across a wide range of devices. As you continue to explore Bootstrap's CSS media queries, remember to test your designs on different devices to ensure they look and function as expected.