In today’s world of rapid development of mobile technologies, web design requires an approach that provides users with an excellent experience regardless of the device or screen size. Responsive Web Design (RWD) is not only a standard but also the foundation of modern website design. Let’s learn about strategies and tools that aim to simplify this process.

A Few Words on RWD

RWD is an approach to web design that ensures a website adapts to various screen sizes and devices while maintaining a consistent and optimal user experience. Viewports can vary widely, ranging from large 4K TVs and desktop monitors to portable devices like laptops, smartphones, and tablets.

Source: Muhammad Rafizeldi for Wikimedia Commons CC-BY-SA 3.0 Unported

The illustration above speaks for itself. Our goal is to ensure every user enjoys seamless and convenient access to our content, no matter the device they use. To users, it’s a given—something they naturally expect. If something seems off, they’re quick to feel disappointed, as most don’t understand the complexities of web development. From their perspective, they might see us as incompetent and simply stop using our software. In a competitive digital landscape, responsiveness can be the difference between retaining a user and losing them forever. That’s why RWD isn’t just good practice; it’s the baseline standard for modern web design.

RWD Techniques: Media Queries, Flexbox, and Grid

Media Queries

Media queries are CSS rules that allow developers to apply different styles based on specific conditions, such as:

  • Viewport size (width and height of the screen),
  • Device orientation (landscape or portrait),
  • Screen resolution (e.g., Retina displays),
  • Other device characteristics (e.g., touchscreens).

Media queries use the @media syntax to specify conditions under which certain styles should be applied. For example:

/* Default styles for all devices */
body {
  font-size: 16px;
}

/* Small devices with a screen width of 768px or less */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
}

/* Large screens with a minimum width of 1200px */
@media (min-width: 1200px) {
  body {
    font-size: 18px;
  }
}

In the above example:

  • On smartphones, the text will be smaller (14px),
  • On large monitors, the text will be larger (18px),
  • On other devices, the text will remain the default (16px).

Media queries are primarily used to create responsive layouts that adapt to different viewports, ensuring a fluid experience across devices. Beyond responsiveness, they also play a key role in optimizing websites, such as enhancing user interfaces for various devices and improving web performance—for example, by loading appropriately sized images.

Flexbox

Flexbox is a powerful CSS layout module designed to create flexible and efficient layouts. It simplifies the process of arranging elements, allowing easy control of alignment, spacing, and distribution of items within a container.

For instance, Flexbox can display a gallery in rows on larger screens and switch to a column layout on smaller devices, ensuring a responsive and user-friendly design. It uses properties like justify-content to control horizontal alignment, align-items for vertical alignment, and flex-wrap to allow items to wrap onto new lines.

Flexbox also streamlines the process of creating layouts that automatically adjust to fit their content, making it a go-to solution for responsive design.

Grid

CSS Grid is another powerful layout module in CSS designed to build complex and flexible layouts. It allows you to create intricate container structures in virtually any way you can imagine while providing full responsiveness to adapt to different viewport sizes. Grid achieves this through properties such as grid-template-columns and grid-template-rows to define the structure, gap to add spacing, and grid-template-areas to create named layout sections.

Example of a grid layout with named sections:

grid-template-areas:
  "header header header"
  "sidebar main main"
  "footer footer footer";

This layout divides the page into a header at the top, a sidebar and main content in the middle, and a footer at the bottom. The header and footer stretch across the entire width, while the sidebar takes up the left side, and the main content fills the rest of the middle row.

Visually, this layout might look like this:

Header | Header | Header
Sidebar | Main   | Main
Footer  | Footer | Footer

Responsive Images

HTML provides a flexible and efficient way to handle displaying images on different screens and viewports. Using the img element with attributes like srcset and sizes, we can easily define image variations and their characteristics.

Example with img:

<img 
  src="default-image.jpg" 
  srcset="image-480w.jpg 480w, image-800w.jpg 800w, image-1200w.jpg 1200w" 
  sizes="(max-width: 600px) 480px, (max-width: 1200px) 800px, 1200px" 
  alt="A descriptive alt text"
/>

In this example:

  • srcset defines the available image sources and their widths.
  • sizes specifies the expected width of the image in the layout depending on the viewport size.

Another great option for responsive images is the picture element, a more advanced approach. It allows to specify different formats (e.g., WebP) or completely different images depending on the user’s device, making it perfect for Responsive Web Design (RWD).

Example with picture:

<picture>
  <source srcset="image-large.webp" type="image/webp" media="(min-width: 1200px)">
  <source srcset="image-medium.webp" type="image/webp" media="(min-width: 600px)">
  <img src="image-small.jpg" alt="A descriptive alt text">
</picture>

In the above:

  • <source> specifies alternate image formats or media conditions.
  • The <img> tag acts as a fallback for browsers that don’t support the <picture> element.

These elements help deliver optimized and visually appealing images across different viewports, ensuring a better user experience and improved performance.

Frameworks and tools

Frameworks and tools offer options for styling layouts to make them responsive. Here are three examples of the most popular ones: Bootstrap, Tailwind CSS, and Foundation.

Bootstrap

Bootstrap is a popular framework that comes with pre-built components and utility classes, making it easy to create responsive designs quickly. One of its key features is the grid system, which allows developers to structure layouts using a flexible, column-based approach.

Example of Bootstrap’s grid system:

<div class="container">
  <div class="row">
    <div class="col-md-6">Column 1</div>
    <div class="col-md-6">Column 2</div>
  </div>
</div>

This grid system automatically adjusts column sizes based on screen width, ensuring responsiveness.

Tailwind CSS

Tailwind CSS is a utility-first framework that provides low-level classes for styling elements directly in HTML. It includes built-in Flexbox and Grid utilities that make responsive design more flexible and customizable.

Example using Tailwind’s Flexbox classes:

<div class="flex flex-col md:flex-row">
  <div class="w-full md:w-1/2 bg-blue-500 p-4">Box 1</div>
  <div class="w-full md:w-1/2 bg-green-500 p-4">Box 2</div>
</div>

In this example:

  • On small screens, the items stack in a column (flex-col).
  • On medium-sized screens and larger (md:flex-row), they align in a row.

Foundation

Foundation is a responsive framework similar to Bootstrap that provides a flexible grid system and UI components. It is known for its mobile-first approach and is excellent for creating accessible and scalable layouts.

Example using Foundation’s grid:

<div class="grid-x grid-padding-x">
  <div class="cell small-6 large-4">Column 1</div>
  <div class="cell small-6 large-4">Column 2</div>
  <div class="cell small-12 large-4">Column 3</div>
</div>

Foundation automatically adjusts the number of columns displayed based on screen size, just like Bootstrap.

Testing Responsive Design

It’s essential to test a website’s responsiveness using various tools to ensure that it looks and functions well across different devices.

Browser DevTools (Chrome, Firefox, Edge)

Most modern browsers provide built-in Developer Tools (DevTools) that allow you to simulate different screen sizes and test how your layout adapts.

In Google Chrome, you can access the responsive testing mode by:

  • Opening DevTools (F12 or Ctrl + Shift + I / Cmd + Option + I on Mac).
  • Clicking the “Toggle Device Toolbar” button (Ctrl + Shift + M / Cmd + Shift + M on Mac).
  • Selecting different devices from the dropdown list to preview how the page looks on various screen sizes.

Additionally, DevTools lets you throttle network speeds to simulate slower mobile connections and inspect how elements behave under different conditions.

Testing on Real Devices

While browser simulations are helpful, real device testing is crucial to catch issues that might not be visible in emulators.

  • Try accessing the site on smartphones, tablets, and desktops with different screen sizes and resolutions.
  • Consider testing touch interactions, scrolling behavior, and performance on lower-end devices.

Cross-Browser Testing

Websites can render differently in various browsers due to differences in their rendering engines. To ensure a consistent experience:

  • Test in Chrome, Firefox, Edge, Safari, and Opera (especially on mobile).
  • For Safari, test on iPhones and iPads since Apple’s browser handles some CSS and JavaScript features differently.
  • Consider using BrowserStack or LambdaTest to run tests on multiple browsers and devices without needing physical hardware.

Online Testing Tools

Several online tools can help verify how a website looks and functions on different devices and browsers:

  • BrowserStack/LambdaTest – Cloud-based services that allow you to test your website on real devices and browsers, including mobile, tablet, and desktop environments.
  • Am I Responsive? – A simple tool to preview your website on different screen sizes (desktop, tablet, mobile).
Source: https://ui.dev/amiresponsive?url=https://makimo.com/

Mobile-first vs. Desktop-first

Mobile-First is one of the most popular approaches to designing websites and applications. In short, it means focusing on mobile devices first—because if something fits on a small screen, it will fit on a larger one, too. Then, the design is gradually expanded with additional elements for tablets and desktops.

Why does this model work? It focuses on mobile responsiveness, which is crucial nowadays, as most people use their phones, and the majority of web traffic comes from mobile devices.

According to reports from StatCounter, mobile users accounted for approximately 63.07% of global web traffic, while desktops comprised 35.07%, and tablets made up 1.86%, making a mobile-first approach more important than ever.

Source: https://gs.statcounter.com/platform-market-share/desktop-mobile-tablet

There are several advantages to this approach. Here are a few of them:

  • Easier design adaptation for developers—it’s simpler to add interface elements rather than remove them later.
  • Better UX on mobile, faster page loading, and higher rankings in Google search.
  • A minimalist design that often provides the best user experience.

What are the potential downsides of this approach?

  • Mobile-First may not work well for complex interfaces that require a lot of interactive elements.
  • It is less relevant for specific desktop-focused projects, such as B2B platforms or professional desktop applications.

Desktop-First, on the other hand, is a rather old-school approach that is less popular nowadays due to the rise of mobile devices. However, it can still be useful in certain cases. Whether it’s a good approach depends on the situation.

When should we use it?

When our target users rely on the product mainly on a desktop, meaning it’s a desktop-oriented application, mobile usage is occasional and not critical.

Examples: Bloomberg Terminal, Power BI, or advanced ERP systems like SAP.

My Thoughts on That!

As a front-end developer who has experienced the struggles of building responsive layouts multiple times, I’ve come to some conclusions. From experience, I can confidently say that problems usually arise when we try to force an overly complex UI. In reality, a simple UI is the key to solving most layout challenges—it makes it much easier to adapt designs to different screen sizes (and let’s be honest, there are a ton of them nowadays!).

As a user, I also prefer fast and simple websites where I don’t have to “learn” how to navigate. So, Mobile-First or Desktop-First? In my opinion, both at the same time! Seriously, it’s much easier to organize the workflow when we have two designs ready—one for mobile and one for desktop—any developer, whether beginner or experienced, can plan their code to accommodate both. Plus, there are plenty of great tools to help with that.

Responsiveness Is More Than Just Design

Remember, RWD is not just about layouts adapting to different screen sizes. It also involves:

  • Performance optimization to ensure fast loading times.
  • Adjusting UI elements, such as buttons and forms, to work seamlessly on touch devices.
  • Maintaining a consistent user experience across all stages of interaction with the website.

Summary

Responsive Web Design (RWD) ensures that websites adapt seamlessly to all screen sizes, providing an optimal user experience and performance. While the Mobile-First approach dominates due to the rise of mobile traffic, Desktop-First remains essential for complex applications where large screens are necessary. However, true responsiveness goes beyond layout—it also includes performance, UI adaptability, and consistency. A well-balanced approach that considers both mobile and desktop from the start leads to the best results.

Curious to check whether your website / application follows standards?

Let’s talk!

Aneta Narwojsz is a dedicated Frontend Developer at Makimo, harnessing her profound expertise in JavaScript and other frontend technologies to deliver remarkable web solutions. Known for her knack for translating complex JavaScript fundamentals into easily digestible content, she regularly publishes enlightening articles and engaging video materials. When she's not immersed in code, Aneta unwinds with her favorite pastimes: visiting the cinema, immersing herself in books, experimenting in the kitchen, and exploring fashion trends.