Mastering Bootstrap 4: Responsive Design with Media Queries

Ruth Jul 09, 2026

Bootstrap 4, the popular front-end framework, offers a robust system of media queries to help you create responsive designs. Media queries allow you to apply different styles based on the characteristics of the device rendering your website. Here, we'll delve into the intricacies of Bootstrap 4 media queries, their syntax, and how to use them effectively.

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

Before we dive in, let's briefly understand why media queries are crucial. With the plethora of screen sizes and types available today, media queries ensure that your website adapts seamlessly to different devices, providing an optimal viewing experience.

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

Understanding Bootstrap 4 Media Queries

Bootstrap 4 uses a mobile-first approach, meaning it styles your website for mobile devices first and then scales up using media queries. This ensures that your website is functional and styled correctly on smaller screens before applying styles for larger ones.

40+ Best Free Bootstrap Templates & Themes in 2026 — Speckyboy
40+ Best Free Bootstrap Templates & Themes in 2026 — Speckyboy

Bootstrap 4 media queries are based on CSS media queries and use the same syntax. They are defined using the @media rule, followed by the media query itself, and then the CSS rules to apply when the query matches.

Bootstrap 4 Breakpoints

Bootstrap 4 Grid System
Bootstrap 4 Grid System

Bootstrap 4 uses five grid tiers, each spanning a range of screen sizes. These tiers are defined by media queries and are often referred to as breakpoints. Here are Bootstrap 4's default breakpoints:

  • Extra small devices (portrait phones, less than 576px)
  • Small devices (landscape phones, 576px and up)
  • Medium devices (tablets, 768px and up)
  • Large devices (desktops, 992px and up)
  • Extra large devices (large desktops, 1200px and up)

Each breakpoint corresponds to a specific media query, which you can use to apply styles for that range of screen sizes.

Bootstrap 5 Classes List Cheat Sheet
Bootstrap 5 Classes List Cheat Sheet

Using Bootstrap 4 Media Queries

To use a Bootstrap 4 media query, you simply need to include the appropriate class in your HTML. For example, to hide an element on small devices and show it on medium devices and up, you would use the following classes:

<div class="d-none d-sm-block">...</div>

The "d-none" class hides the element, while the "d-sm-block" class shows it on medium devices and up.

the different types of font and numbers
the different types of font and numbers

Customizing Bootstrap 4 Media Queries

While Bootstrap 4's default breakpoints cover most use cases, you may sometimes need to customize them. You can do this by modifying the Sass variables in your Bootstrap 4 source files.

Thinking in Bootstrap 4, theming with Vartheme BS4 Cheat Sheet
Thinking in Bootstrap 4, theming with Vartheme BS4 Cheat Sheet
Wizard
Wizard
Bootstrap 4 Admin Dashboard Template
Bootstrap 4 Admin Dashboard Template
How To Center a div Horizontally in Bootstrap 4
How To Center a div Horizontally in Bootstrap 4
Understanding the Bootstrap 4 Grid System
Understanding the Bootstrap 4 Grid System
an image of a dashboard screen with different colors and numbers on it, as well as the
an image of a dashboard screen with different colors and numbers on it, as well as the
Bootstrap Photo Gallery
Bootstrap Photo Gallery
an image of a web page with many different things on it, including food and drinks
an image of a web page with many different things on it, including food and drinks
HOT GADGETS e-commerce web page
HOT GADGETS e-commerce web page
a desktop computer with the title how to create a responsive website with bootstrap 4 for beginners
a desktop computer with the title how to create a responsive website with bootstrap 4 for beginners
Bootstrap 4 Tutorial: Create a One-Page Template
Bootstrap 4 Tutorial: Create a One-Page Template
How the Bootstrap 4 Grid Works
How the Bootstrap 4 Grid Works
Responsive Bootstrap Website Start To Finish with Bootstrap 4, HTML5, CSS3 & jQuery
Responsive Bootstrap Website Start To Finish with Bootstrap 4, HTML5, CSS3 & jQuery
Webstrot Admin Panel Responsive Bootstrap Dashboard Template
Webstrot Admin Panel Responsive Bootstrap Dashboard Template
Bootstrap 4 Quick Start: Quiz
Bootstrap 4 Quick Start: Quiz
100+ Best Free Bootstrap Templates 2024
100+ Best Free Bootstrap Templates 2024
Bootstrap Snippets Library & Layout Examples [Code Demos] | BootstrapCreative
Bootstrap Snippets Library & Layout Examples [Code Demos] | BootstrapCreative
Bootstrap Themes at BootstrapZero
Bootstrap Themes at BootstrapZero
Qixa Admin Template
Qixa Admin Template
Bootstrap Tutorial – Introduction
Bootstrap Tutorial – Introduction

For instance, to change the medium device breakpoint from 768px to 800px, you would update the $grid-breakpoints variable in the Bootstrap Sass files:

$grid-breakpoints: (
  xs: 0,
  sm: 800px,
  md: 992px,
  lg: 1200px,
  xl: 1400px
);

After making your changes, recompile your Sass to apply the new breakpoints.

Responsive Images with Bootstrap 4

Bootstrap 4 also includes classes to help you create responsive images. By adding the "img-fluid" class to an image, it will resize itself based on its parent element, maintaining its aspect ratio.

To display different images based on the screen size, you can use the "img-fluid" class in combination with the media query classes. For example, to display a different image on medium devices and up:

<img src="image-small.jpg" srcset="image-medium.jpg 768w" class="img-fluid d-none d-sm-block" alt="Responsive image">

In the world of responsive web design, Bootstrap 4 media queries are indispensable tools. They allow you to create dynamic, adaptable websites that look great on any device. So, harness their power and watch your designs come to life!