tezvyn:

Mobile-First Design: Start Small, Then Scale Up

AI-drafted, machine-checkedSource: developer.mozilla.orgintermediate
Mobile-First Design: Start Small, Then Scale Up

Mobile-first design means building for the smallest screen first, then enhancing for larger ones. This ensures a solid baseline experience on phones, where most users are. The footgun is thinking it's just CSS, not a content-first strategy.

WHY IT EXISTS The old approach to web design was desktop-first. Developers built a complex site for large screens and then tried to shrink or hide parts of it to fit a phone, a process called "graceful degradation." This often resulted in slow, clunky, and frustrating mobile experiences. As mobile traffic began to dominate, a better approach was needed that treated phones as first-class citizens, not afterthoughts.

THE MENTAL MODEL Think of it like packing for a trip. With a small backpack (mobile), you pack only the absolute essentials. If you later get a bigger suitcase (desktop), you can add more luxury items (extra features, sidebars, complex layouts), but your core essentials are already packed and ready. The reverse—trying to cram a suitcase's contents into a backpack at the last minute—is a mess.

HOW IT WORKS Mobile-first is both a strategy and a technical pattern. Strategically, it forces you to identify the core content and functionality of your application. What is the one thing a user must be able to do? That's your starting point. Technically, this is implemented with CSS using min-width media queries. You write your base styles for the smallest screens first. Then, as the screen size increases, you use media queries like @media (min-width: 768px) to add styles, change layouts, and reveal more complex components. This is a form of progressive enhancement.

WHEN TO USE IT This is the default, recommended approach for virtually all new web projects. It's especially critical for public-facing websites, e-commerce platforms, and news sites where mobile traffic often exceeds 50%. It encourages better performance, accessibility, and a more focused user experience by forcing you to prioritize.

WHEN NOT TO USE IT The only real exceptions are for applications that are guaranteed to be used only on desktops. Examples include complex, specialized internal tools like a network operations dashboard or a professional video editing web app. Even in these cases, using a responsive approach is often wise for future-proofing. The desktop-first approach is now considered a legacy practice.

ONE CANONICAL EXAMPLE A site's navigation. In a mobile-first design, the default style would be a simple "hamburger" menu icon that toggles a vertical list of links. This works well on a narrow screen. Then, you'd add a media query for a minimum width, say 1024px, that transforms the navigation into a full, horizontal bar across the top of the page. You start with the simple, universal solution and add the more complex layout for screens that can support it.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.