Omar CodePlay logo
Back to Articles

Responsive Design: Making Websites Work on Every Screen

Introduction: The Web is Everywhere

People browse the internet on phones, tablets, laptops, widescreen monitors, and smart TVs — all with completely different screen sizes. A website that looks great on a large desktop but breaks on a phone is not a finished website. More than 60% of all web traffic today comes from mobile devices.

Part 1: The Viewport — Your First Step

Before any CSS, you need one line of HTML in the head of every page you build:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

This tells the browser: "Use the actual screen width as the viewport width." It's the foundation of every responsive website.

Part 2: Media Queries — Adapting to Screen Size

A media query lets you write CSS rules that only apply when certain conditions are true — most commonly, when the screen width is above or below a certain size. Common breakpoints to design for:

Part 3: Mobile First Design

The professional approach is mobile first: design for the smallest screen first, then add media queries to expand the layout as the screen gets larger. This forces you to prioritize what matters most. On a small screen, you can only show the essentials.

Part 4: Flexbox and Grid for Responsive Layouts

Flexbox is great for laying out items in a single row or column. It lets items grow, shrink, and wrap automatically based on available space.

CSS Grid is for two-dimensional layouts — rows and columns at the same time. It's perfect for full page layouts: header, sidebar, main content, and footer.

Part 5: Responsive Images and Text

For images, always set max-width: 100% — this ensures images never overflow their container on small screens. For text, use relative units like rem instead of fixed pixel sizes. The CSS clamp() function lets you set a minimum, ideal, and maximum font size in one line.

Conclusion: Responsive Design is Respect for Your Users

Building a responsive website is a way of saying: "No matter what device you're on, I've designed this experience for you." In a world where most browsing happens on phones, it's not optional — it's the baseline.

"Design is not just what it looks like. Design is how it works — on every screen, for every user."