Bootstrap 5 Grid: Medium Devices
The medium tier (md) starts at 768px — a tablet in portrait orientation. It's the most popular breakpoint for page layouts: below 768px you design for phones (one column), from 768px you have room for a sidebar or two to three columns.
| Tier | Infix | Range | .container width |
|---|---|---|---|
| Medium | md |
768px and up | 720px (until 992px) |
Medium columns
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="py-2">
<div class="container">
<p class="small mb-2">Frame width: <strong id="w"></strong> —
<span class="d-md-none text-danger">below md: stacked</span>
<span class="d-none d-md-inline text-success">md or wider: side by side</span>
</p>
<div class="row g-2">
<div class="col-md-6"><div class="p-3 text-bg-primary rounded">col-md-6</div></div>
<div class="col-md-6"><div class="p-3 text-bg-secondary rounded">col-md-6</div></div>
</div>
</div>
<script>document.getElementById('w').textContent = window.innerWidth + 'px';</script>
</body>
</html>Note: The lesson column is often close to 768px wide, so this is the tier where the preview frame is most likely to sit right at the edge. Make your browser window a little narrower or wider and run again to see both versions. You can drag the frame's bottom-right corner to give it more height.
Combining sm and md
Classes add up across tiers. Here: stacked on phones, 50/50 from sm, 33/66 from md.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>.row > div > div { background: #e9dffb; border: 1px solid #7952b3; padding: .6rem; font-size: .85rem; }</style>
</head>
<body class="py-2">
<div class="container">
<div class="row g-2">
<div class="col-sm-6 col-md-4"><div>col-sm-6 col-md-4</div></div>
<div class="col-sm-6 col-md-8"><div>col-sm-6 col-md-8</div></div>
</div>
</div>
</body>
</html>| Width | Column 1 | Column 2 |
|---|---|---|
| < 576px | 100% | 100% |
| 576–767px | 50% | 50% |
| ≥ 768px | 33.3% | 66.7% |
Offsets and ordering at md
Offsets and order classes also take tiers. A common trick: show an image above the text on phones but on the right from md, using order-md-last.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="py-2">
<div class="container">
<div class="row g-3 align-items-center">
<div class="col-md-5 order-md-last">
<div class="ratio ratio-4x3 rounded-3" style="background: linear-gradient(135deg, #20c997, #0d6efd);">
<div class="d-flex align-items-center justify-content-center display-4">🐳</div>
</div>
</div>
<div class="col-md-7">
<h5>Meet the whale</h5>
<p class="small mb-0">On phones the picture is first in the HTML, so it shows on top. From md, <code>order-md-last</code> moves it to the right.</p>
</div>
</div>
<div class="row mt-3">
<div class="col-md-6 offset-md-3"><div class="p-2 border rounded text-center small">col-md-6 offset-md-3 (centred from md)</div></div>
</div>
</div>
</body>
</html>A medium-tier form
Forms often switch at md too: one field per line on phones, several per line on tablets and up.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="py-2">
<div class="container">
<form class="row g-2">
<div class="col-md-5"><input class="form-control" placeholder="Street" aria-label="Street"></div>
<div class="col-md-4"><input class="form-control" placeholder="City" aria-label="City"></div>
<div class="col-md-3"><input class="form-control" placeholder="ZIP" aria-label="ZIP"></div>
<div class="col-12 col-md-auto ms-md-auto d-grid"><button class="btn btn-primary" type="button">Save address</button></div>
</form>
</div>
</body>
</html>The button is full-width on phones (col-12 + d-grid) and shrinks to its content, pushed to the right, from md (col-md-auto ms-md-auto).
Tip: If you only learn one responsive tier, learn md.
col-md-*for layout,d-none d-md-blockfor "desktop-only" bits andd-md-nonefor "phone-only" bits cover a huge number of real-world designs.
Test yourself
At what width does the md tier start?
- 576px
- 768px
- 992px
- 1024px
With col-sm-6 col-md-4, how wide is the column at 700px?
- 100%
- 50%
- 33.3%
- 4px
Which class moves a column to the end only from md up?
- .order-last
- .order-md-last
- .md-last
- .offset-md-last