Responsive Classes in Bootstrap
Bootstrap‘s Responsive Classes are what allow a website to look fantastic on anything from a tiny iPhone to a ginormous 4K monitor. They allow you to swap an element‘s width, visibility, or margin depending on the size of the display.
1. Responsive Column Classes
This is the most frequent use of responsive classes. You are telling the browser: “On this size screen, use this much space.”
The Example: A 3-Column Layout
Imagine you have three service boxes (Web Design, SEO, and Marketing).
- On Mobile: You want them to stack vertically so they are easy to read.
- On Tablet: You want two on top and one below.
- On Desktop: You want all three in one neat row.
The Code Logic:
class="col-12 col-md-6 col-lg-4"
col-12: (Mobile) Takes up all 12 slots. The boxes stack.col-md-6: (Tablet) Takes up 6 slots. Since $6 + 6 = 12$, two fit on one row, and the third drops down.col-lg-4: (Desktop) Takes up 4 slots. Since $4 + 4 + 4 = 12$, all three fit perfectly in one row.
2. Responsive Display Classes (Hiding/Showing)
Occasionally, even though the content looks nice and pristine on the laptop, it ends up clumping together and confusing on a phone. The class d-{size}-{value} will hide content depending on the size of the screen.
d-none: Hidden on all screens.d-md-block: Visible as a “block” element starting at Medium screens.
Example: You have a “Live Chat” button that is too distracting on mobile.
- Class:
class="d-none d-lg-inline-block" - Result: The button is invisible on phones and tablets but appears on laptops and desktops.
3. Responsive Spacing (Margins & Padding)
Spacing has to increase with wider screens. Using a large to on a phone will feel like an error, but on a desktop it looks “premium”.
- Formula:
m{side}-{size}-{value}orp{side}-{size}-{value} - Example:
class="mt-2 mt-md-5"mt-2: On mobile, the Margin Top is small (level 2).mt-md-5: Starting at tablet size, the Margin Top grows to a large gap (level 5).
4. Responsive Text Alignment
Center-aligning text on mobile often looks better, while left-aligning looks better on desktop.
- For example: class=“text-center text-md-start” The class applies styles when the viewport is more than 768 pixels wide. You can combine classes by placing them in the same class attribute, separating each class name by a space..
text-center: Text is centered by default (Mobile).text-md-start: Text aligns to the left (Start) once the screen reaches tablet size.
Check out our resources!
- Bootstrap Templates: Explore our Bootstrap Projects section.
- Free E-Books: Download your Free E-Books here.


