2026-04-01|Frontend
Responsive Design Best Practices: Build for All Devices
What is Responsive Design?
Back in the day, we built separate websites for desktop and mobile. Remember "m.example.com"? Thank goodness those days are mostly over. Responsive design means one codebase that adapts to any screen size.
It sounds simple in theory, but in practice, there are plenty of gotchas. Here's what I've learned from building responsive interfaces that actually work across devices.
Mobile-First Approach
Start designing for the smallest screen and scale up:
/* Base styles for mobile */
.container {
padding: 16px;
}
/* Tablet */
@media (min-width: 768px) {
.container {
padding: 24px;
max-width: 720px;
}
}
/* Desktop */
@media (min-width: 1024px) {
.container {
padding: 32px;
max-width: 960px;
}
}
Fluid Typography
Use relative units for scalable text:
html {
font-size: 16px;
}
h1 {
font-size: clamp(1.5rem, 4vw, 2.5rem);
}
p {
font-size: clamp(0.875rem, 2vw, 1rem);
}
Flexible Layouts
CSS Grid
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
}
Flexbox
.flex-container {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.flex-item {
flex: 1 1 300px;
}
Responsive Images
<img srcset="small.jpg 480w, medium.jpg 800w, large.jpg 1200w"
sizes="(max-width: 600px) 100vw, 50vw"
src="medium.jpg" alt="Description">
Common Breakpoints
/* Mobile: 0 - 479px */
/* Tablet: 480px - 767px */
/* Desktop: 768px - 1023px */
/* Large Desktop: 1024px+ */
@media (min-width: 480px) { /* Tablet */ }
@media (min-width: 768px) { /* Desktop */ }
@media (min-width: 1024px) { /* Large Desktop */ }
Touch-Friendly Design
- Minimum touch target: 44px x 44px
- Adequate spacing between interactive elements
- Avoid hover-dependent interactions on mobile
- Use larger fonts for readability
Testing Responsiveness
- Browser DevTools responsive mode
- Physical device testing
- Chrome Lighthouse
- Cross-browser testing tools
Performance on Mobile
- Optimize images for mobile connections
- Minimize JavaScript execution
- Use lazy loading
- Reduce HTTP requests
Building T-Tools for Every Device
T-Tools was designed mobile-first from day one. Here's what I learned:
- Test on real devices: Emulators are good, but nothing beats testing on actual phones. I keep 3 test devices: an iPhone, a Samsung Galaxy, and a budget Android phone.
- Touch targets matter: My first design had buttons that were 32px — too small for thumbs. I increased all interactive elements to at least 44px.
- Test slow connections: Use Chrome DevTools to simulate 3G. Many of our users access tools from mobile networks in developing countries.
- Font scaling: Using
clamp()for font sizes was a game-changer. It eliminates most media queries for typography.
The result: T-Tools works beautifully on everything from a 4-inch phone to a 27-inch monitor.