Welcome to Arc D: Responsive Design

You've learned HTML structure and CSS styling. Now comes a critical skill: making your pages work on every device. In 2026, over 75% of web traffic comes from mobile devices. A website that looks beautiful on your 27-inch monitor but is broken on a phone is a broken website.

Arc D teaches you responsive design โ€” the modern approach to building websites that adapt to any screen size. By the end of this arc, you'll understand viewport meta tags, fluid layouts, mobile-first CSS, and responsive images.

Key principle:
Responsive design means your CSS adapts to the user's device, not the other way around. Start with mobile (the smallest screen), then add complexity for larger screens.

The viewport meta tag

The first step to responsive design is telling the browser how to render your page on mobile. Without the viewport meta tag, mobile browsers assume your page is designed for desktop and zoom out, making text tiny and unreadable.

index.html The essential viewport meta tag

Let's break down the viewport meta tag:

  • width=device-width โ€” Sets the viewport width to match the device's actual width. On a phone, this is typically 375px. On a tablet, 768px. On a desktop, 1920px or more.
  • initial-scale=1.0 โ€” Sets the initial zoom level to 100% (no zoom). The page starts at normal size, not zoomed in or out.

Always include this line in every HTML page you create. Without it, your responsive CSS won't work on mobile devices.

Pro tip:
You may see user-scalable=no in older pages. Don't use it โ€” users have the right to zoom if they need to. Always allow zooming.

Fluid widths: %, vw, and vh

Fixed pixel widths break on small screens. If you set a container to width: 1000px, it overflows on a phone. The solution: fluid widths that adapt to the viewport.

responsive.css Three types of fluid units

Key fluid units:

  • % โ€” Relative to the parent container. Use for layout widths (containers, columns, sections).
  • vw โ€” Viewport width. 1vw = 1% of the browser window width. Use sparingly for full-viewport designs.
  • vh โ€” Viewport height. 1vh = 1% of the browser window height. Great for hero sections that fill the screen.
  • clamp(min, preferred, max) โ€” Smart scaling. The value scales, but never goes below min or above max.
Best practice:
Combine width: 90% with max-width to stay readable on large screens while fitting phones. Never use fixed pixel widths for layout.

Try it yourself: Fluid widths

Edit the CSS below. Change the container width, adjust the max-width, and watch how the layout adapts as you resize your window.

โœ๏ธ Try It Yourself โ€” Fluid Layout
Preview

Responsive images

Images are often the culprit in unresponsive designs. A 2000px-wide image on a phone is ridiculous โ€” it overflows, forces horizontal scrolling, and wastes bandwidth.

responsive.css Making images responsive

The golden rules for responsive images:

  • max-width: 100% โ€” The image never stretches wider than its container.
  • height: auto โ€” The height scales proportionally so the image doesn't distort.
  • object-fit: cover (optional) โ€” Crop the image to fill its container while maintaining aspect ratio.
Performance tip:
Use CSS max-width: 100% but also use responsive image formats like WebP and size images appropriately before uploading. Large images waste bandwidth on mobile.

Mobile-first CSS approach

There are two ways to write responsive CSS:

  • Desktop-first: Write CSS for desktop, then use media queries to shrink for mobile. This often leads to bloated, complex code.
  • Mobile-first (recommended): Write CSS for mobile first (the smallest screen), then use media queries to enhance for larger screens. This results in cleaner, faster code.

Mobile-first is recommended because:

  • Most users are on mobile โ€” optimize for them first.
  • Progressive enhancement: Start simple, add features for capable devices.
  • Smaller CSS file size (fewer overrides).
  • Forces you to think about performance and usability from the start.
mobile-first.css Mobile-first approach

Notice the pattern: base styles (mobile), then @media (min-width: 768px) for tablets, then @media (min-width: 1024px) for desktops. This is mobile-first.

Try it yourself: Mobile-first CSS

This example starts with single-column mobile layout and expands to multiple columns on larger screens. Resize your browser to see the layout change.

โœ๏ธ Try It Yourself โ€” Mobile-First Layout
Preview

Key concepts recap

  • Viewport meta tag: <meta name="viewport" content="width=device-width, initial-scale=1.0"> is essential. It tells mobile browsers to render at device width, not zoomed out.
  • Fluid widths: Use %, vw, vh, and clamp() instead of fixed pixel widths. Never set width: 1000px on a layout.
  • Responsive images: Always use max-width: 100% and height: auto so images scale with their container.
  • Mobile-first: Write base CSS for mobile (small screens), then expand with @media queries for tablets and desktops.
  • Media queries: Use @media (min-width: 768px) and up, not max-width. This keeps mobile CSS clean and uncluttered.
Challenge: Build a Responsive Page

Task: Create a responsive page with:

  • The viewport meta tag (required!)
  • A fluid container using width: 90%; max-width: 1000px;
  • A responsive image with max-width: 100%; height: auto;
  • Fluid typography using clamp() for the heading
  • A mobile-first grid: 1 column on mobile, 2 on tablet (640px+), 3 on desktop (1024px+)

Hint: Start with the mobile layout. Write all your base CSS for small screens first. Then add @media (min-width: 640px) and @media (min-width: 1024px) blocks to enhance for larger screens. Remember: mobile first!

Key takeaways

  • Always include the viewport meta tag. Without it, mobile browsers won't render your responsive CSS correctly.
  • Never use fixed pixel widths for layout. Use %, vw, vh, and clamp() instead.
  • Images need max-width: 100% and height: auto to scale responsively.
  • Mobile-first CSS is the modern standard. Write for small screens first, then enhance for larger screens with media queries.
  • Responsive design isn't a luxury โ€” it's a requirement. Over 75% of users browse on mobile.

Test your knowledge

Question 1 of 5
What does the viewport meta tag width=device-width do?
Question 2 of 5
What does max-width: 100% do on images?
Question 3 of 5
What is mobile-first design?
Question 4 of 5
Which CSS unit is relative to the viewport width?
Question 5 of 5
Why is mobile-first recommended over desktop-first?
0
/5
Excellent! You understand responsive design.
Africa & India's Best AI Academy
๐Ÿค– AI-first ๐ŸŽ“ Placement Assistance

You just built responsive pages.
Imagine the full-stack sites you'll create next.

Join the Best AI Programs โ€” three 5-month courses, fully online, with placement assistance. Week 1 is free.

Explore our AI-era courses โ†’