Responsive CSS
Using responsive CSS is a form of SEO that allows for multiplatform screen support.
Screen sizes
The majority of web traffic is on mobile
- Mobile ยท 60%
- Desktop ยท 40%
Devices
- Watch
- Mobile
- Tablet
- Laptop
- Desktop
- TV
Stats Counter โ Screen Resolution Market Share
Screen Size Map
Common Breakpoints
Dev Tools
| Mobile S | 320px |
| Mobile M | 375px |
| Mobile L | 425px |
| Tablet | 768px |
| Laptop | 1024px |
| Laptop L | 1440px |
| 4K | 2560px |
Dev Tools โ Responsive viewport mode
CSS Frameworks
| Tailwind | Bootstrap | Chakra | Primer | MUI | |
|---|---|---|---|---|---|
| Small | 40rem 640px |
576px |
420px |
544px |
600px |
| Medium | 48rem 768px |
768px |
768px |
768px |
900px |
| Large | 64rem 1024px |
1024px |
1024px |
1004px |
1200px |
| XLarge | 80rem 1280px |
1280px |
1280px |
1280px |
1536px |
| 2XLarge | 96rem 1536px |
1536px |
1536px |
โ | โ |
Tailwind โ Breakpoints
Bootstrap โ Breakpoints
Chakra โ Breakpoints
Primer โ Breakpoints
MUI โ Breakpoints
Common Page Widths
Documentation
688px 43rem |
VitePress Zensical Microsoft SharePoint |
720px 45rem |
Notion Starlight |
740px |
VuePress |
760px |
Fumadocs |
768px 48rem |
GitBook Confluence |
816px 8.5in |
Google Drive |
825px |
Material MkDocs Zensical |
832px 52rem |
Nextra |
920px |
Microsoft Loop |
CSS Frameworks
Viewport
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> Scales the page properly on mobile
MDN Web Docs โ Meta viewport
CSS Layout
Reset default style
Setting
width: 100vw;on<body>causes a horizontal scrollbar defect
Content
<main> <section id='hero'></section> <section id='about'></section> <section id='contact'></section></main>}Use
section > div.wrapperto allow different background colors for individual sections
Header
<header> <!-- logo --> <a href="/" class="logo"> <img src="/logo.svg" width="64" height="64" alt="Logo"/> </a> <!-- pages --> <nav> <ul> <li><a href="/blog">Blog</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul> </nav> <!-- mobile menu --> <label class="menu"> <input type='checkbox' name='menu' hidden/> <img src="/menu.svg" width="64" height="64" alt="Menu"/> </label></header>header {Tweaked <main> โ 4 collapsed lines
max-width: 720px; margin-inline: auto; padding-inline: 1em; /* display: flow-root; */ display: grid; gap: 1em;
nav { โ<nav> Layout on Desktop
display: flex; justify-content: center; gap: 1em; }
.logo { }
.mobile { display: none; โThe mobile menu icon is only displayed on mobile
}
}
@media (max-width: calc(175px + 4em)) { Navbar layout on mobile
- Size of
<nav> ยท 175px + Size of total spacing 4em
@media does not support var()
header { padding-bottom: 1em;
.menu { display: block; } โThe mobile menu icon is displayed on mobile
nav { grid-row: 2; flex-direction: column; The <nav> is Vertical on mobile
gap: 0.5em; } }
header:has(input[name='menu']:not(:checked)) { โThe <nav> is displayed only when the menu is open on mobile
padding-bottom: 0em;
nav { display: none; } }}Footer
<footer> <section id="footer">Brand โ 19 collapsed lines
<!-- brand --> <hgroup class="brand"> <!-- logo --> <h2> <a href="/" class="logo"> <img src="/logo.svg" width="64" height="64" alt="Logo"/> </a> </h2> <!-- headline --> <p>...</p> <!-- social media --> <nav class="social-media" aria-label="Social Media"> <ul> <li><a rel="me" href="https://github.com/..." aria-label="GitHub">GitHub</a></li> <li><a rel="me" href="https://discord.com/..." aria-label="Discord">Discord</a></li> <li><a rel="me" href="https://twitter.com/..." aria-label="X">X</a></li> </ul> </nav> </hgroup> <!-- pages --> <nav> <hgroup> <h3>About</h3> <ul> <li><a href="/story">Story</a></li> <li><a href="/help">Help</a></li> <li><a href="/community">Community</a></li> </ul> </hgroup> <hgroup> <h3>Blog</h3> <ul> <li><a href="/getting-started">Getting Started</a></li> <li><a href="/technical-notes">Technical Notes</a></li> <li><a href="/news">What's New</a></li> </ul> </hgroup> </nav> </section>Additional sections โ 15 collapsed lines
<section id="legal"> <!-- copyright --> <p>© 2026 Site, Inc. All rights reserved.</p> <!-- legal documents --> <nav aria-label="Legal Navigation"> <ul> <li><a rel="privacy-policy" href="/privacy">Privacy Policy</a></li> <li><a rel="terms-of-service" href="/terms">Terms of Service</a></li> </ul> </nav> </section> <section id="credit"> <!-- credit --> <p>Designed and built by <a href="/about" rel="author">Stephcraft</a></p> </section> </footer>footer {Tweaked <main> โ 4 collapsed lines
max-width: 720px; margin-inline: auto; padding-inline: 1em; section { display: flow-root; }
section#footer { margin-bottom: 1em;
Brand โ 9 collapsed lines
display: flex; flex-wrap: wrap; gap: 1em;
hgroup.brand > nav.social-media { display: flex; justify-content: center; gap: 1em; }
nav { โ Row layout
display: flex; justify-content: space-around; flex-wrap: wrap; }
hgroup { Column layout
display: flex; flex-direction: column; margin-bottom: 1em; } }
Additional sections โ 8 collapsed lines
section#legal { nav { display: flex; justify-content: center; gap: 1em; margin-block: 1em; } }
p { text-align: center; }
}Aside
<aside id='documents'></aside><main> <section id='hero'><section> <section id='about'></section> <section id='contact'></section></main><aside id='table-of-contents'></aside> display: grid; /* [ 1fr ][ min/max ][ 1fr ] [ left ][ content ][ right ] [ full ] */ grid-template-columns: [full-start left-start] 1fr [content-start left-end] minmax(auto, calc(720px + 1em * 2)) โSet the page width
- The Horizontal spacing should be defined in either
calc() or gap
minmax(auto, 720px) is equivalent to max-width: 720px
[content-end right-start] 1fr [full-end right-end];}
main, header, footer {Tweaked <main> โ 5 collapsed lines
max-width: 720px; /* margin-inline: auto; */ padding-inline: 1em; display: flow-root; box-sizing: border-box; }
/* left <aside> */aside:has(+ main) {}
/* right <aside> */main + aside {}
aside {}
@media (max-width: calc(720px + 150px + 150px)) { Remove <aside> on smaller screens ยท this one is removed first
- Size of
<main> ยท 720px + Size of both <aside> 150px + 150px
@media does not support var()
aside#table-of-contents { display: none; }}
@media (max-width: calc(720px + 150px)) { Remove <aside> on smaller screens ยท this one is removed last
- Size of
<main> ยท 720px + Size of this <aside> 150px
@media does not support var()
aside#documents { display: none; }}Media
Image
<img src="image.png"/>img { display: block; โ Images are inline by default causing a bottom offset defect
- Inline elements follow the text baseline height
}Web.dev Docs โ Responsive images
Picture
<picture> <source srcset="image-portrait.png" media="(orientation: portrait)"/> Image displayed in portrait orientation
<source srcset="image-landscape.png" media="(orientation: landscape)"/> Image displayed in landscape orientation
<img src="image-landscape.png"/> โFallback Image
</picture> Web.dev Docs โ Picture element
MDN Web Docs โ Picture element
Video
<video autoplay loop> <source src="image-portrait.png" type="video/mp4" media="(orientation: portrait)"/> Video displayed in portrait orientation
<source src="image-landscape.png" type="video/mp4" media="(orientation: landscape)"/> Video displayed in landscape orientation
</picture>video {}Typography
Text units
Fluid text size
body {}Utopia โ Fluid Type clamp generator
Text overflow
<p class='ellipsis'>Luxury-grade software craftsmanship across Minecraft modding, developer tooling, and interactive experiences, backed by 10 years of hands-on development.</p> โ Clip text and suffix with ...
<p>Luxury-grade software craftsmanship across <strong>Minecraft modding</strong>, <strong>Developer tooling</strong>, and <strong>Interactive experiences</strong>, backed by 10 years of hands-on development.</p> โstrong text break on the same line
p.ellipsis {}
p strong {}
@media (max-width: 200px) { p strong { }}
body {}Type scale system
<h1>Title</h1><h2>Subtitle</h2><h3>Heading 3</h3><h4>Heading 4</h4><h5>Heading 5</h5><h6>Heading 6</h6><p>Paragraph</p>h1 { font-size: 2em; margin-block: 0.67em; /* 2:3 */}
h2..h6 โ 24 collapsed lines
h2 { font-size: 1.5em; margin-block: 0.83em; /* 5:6 */}
h3 { font-size: 1.17em; /* 7:6 */ margin-block: 1em;}
h4 { font-size: 1em; margin-block: 1.33em; /* 4:3 */}
h5 { font-size: 0.83em; /* 5:6 */ margin-block: 1.67em; /* 5:3 */}
h6 { font-size: 0.67em; /* 2:3 */ margin-block: 2.33em; /* 7:3 */}
p { font-size: 1em; margin-block: 1em;} Utopia โ Fluid Type scale generator
GitHub โ Default heading styles
Collection
Flex
<div class='flex'> {data.map((tag) => ( <div class='tag'>{tag}</div> ))}</div>.flex { display: flex;}Grid
<div class='grid'> {data.map(([image, title]) => ( <div class='card'> <img src={image} alt={title}/> <h3>{title}</h3> </div> ))}</div>.grid { display: grid;}Conditional
Stylesheet links
<link rel="stylesheet" href="/style.css"/><link rel="alternate stylesheet" href="/desktop.css" media="(min-width: 800px)"/><link rel="alternate stylesheet" href="/mobile.css" media="(max-width: 800px)"/>MDN Web Docs โ Link media queries
Stylesheet imports
@import "style.css";@import "desktop.css" (min-width: 800px);@import "mobile.css" (max-width: 800px);MDN Web Docs โ CSS import media queries
Document styles
@media (min-width: 720px) {}@media (max-width: 720px) {}@media (hover: none) {}MDN Web Docs โ CSS media queries
Container styles
.container { container-type: inline-size;}
@container (min-width: 400px) {}MDN Web Docs โ CSS container queries
Tools
Testing
Typography
Utopia โ Fluid Type clamp generator
Utopia โ Fluid Type scale generator
Resources
MDN Web Docs โ Responsive web design
MDN Web Docs โ CSS media queries
Web.dev โ Learn Responsive Design
Wikipedia โ Responsive web design
Additional Resources
Josh Comeau โ Full-Bleed Layout Using CSS Grid
Web.dev Docs โ Modern layouts
Web.dev Docs โ Responsive web design
Web.dev Docs โ Responsive typography
Web.dev Docs โ Responsive images
Web.dev Docs โ Component-driven responsive web design
W3Schools Docs โ Responsive Web Design
W3Schools Docs โ HTML and CSS Responsive Design