Protected Learning Content

AICPE Gurukul content is created for learning purposes. Printing, copying and unauthorized reuse are restricted.

AICPE Learning Hub HTML with CSS
Chapter 21
Responsive Web Design
Chapter 21 | Mobile Friendly Design

Responsive Web Design

A responsive website adjusts beautifully on mobile, tablet and desktop screens. In this chapter, you will learn viewport, flexible layouts, media queries and mobile-first design.

Viewport

Allows webpage to fit device width properly.

Fluid Layout

Uses flexible width instead of fixed width only.

Media Queries

Applies CSS based on screen size.

Breakpoints

Screen sizes where layout changes.

Learning Objectives

After This Chapter, You Will Understand

This chapter helps you build webpages that work smoothly on all screen sizes.

Viewport

Use viewport meta tag for mobile-friendly pages.

Fluid Width

Use %, max-width and flexible units.

Media Queries

Apply different styles at different screen sizes.

Responsive Layout

Make cards, menus and grids adapt to devices.

Responsive Meaning

What is Responsive Web Design?

Responsive web design means creating websites that adjust according to the user's screen size.

1 Simple Meaning

A responsive webpage looks good and remains usable on mobile phones, tablets, laptops and desktop screens. Text, images, menus, cards and layouts should adjust automatically.

Definition: Responsive web design is a technique where webpage layout and content adapt to different screen sizes and devices.
Professional Tip: Most visitors use mobile devices, so mobile-friendly design is essential for modern websites.
Mobile
Tablet
Desktop
Viewport

Viewport Meta Tag

The viewport meta tag tells the browser how to scale the webpage on different devices.

2 Required Meta Tag

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

This tag should be included in the head section of every responsive webpage.

3 Meaning

  • width=device-width: page width matches device width
  • initial-scale=1.0: page starts at normal zoom level
  • Improves mobile display
  • Prevents desktop-style shrinking on mobile
Remember: Without viewport tag, mobile layout may look zoomed out or difficult to read.
Fluid Layout

Flexible Width and Images

Responsive design uses flexible sizes instead of only fixed pixels.

Flexible Container

width:80%; max-width:420px;

Element can shrink and grow with screen size.

Flexible Image

img {
  max-width: 100%;
  height: auto;
}

Images should not overflow outside their container.

Responsive Cards

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

Cards automatically adjust according to available width.

Quick Rule: Avoid fixed widths for major layouts. Use width:100%, max-width, %, fr, auto-fit and minmax where suitable.
Media Queries

Changing CSS Based on Screen Size

Media queries allow CSS to change when the screen becomes smaller or larger.

4 Basic Media Query

.cards {
  grid-template-columns: repeat(3, 1fr);
}

@media(max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

5 Common Breakpoints

Device Common Width
Mobile up to 600px
Tablet 601px to 992px
Laptop 993px to 1200px
Desktop 1200px+
Practice Task: Create a three-column card layout and convert it into one column below 768px.
Mobile First

Mobile-First Design

Mobile-first means designing for small screens first, then enhancing for larger screens.

6 Mobile-First Approach

In mobile-first CSS, the default design is for mobile screens. Then we add media queries for tablets and desktops.

/* Mobile default */
.cards {
  display: grid;
  grid-template-columns: 1fr;
}

/* Tablet and desktop */
@media(min-width: 768px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

7 Responsive Checklist

  • Add viewport meta tag
  • Use flexible containers
  • Use max-width for images
  • Use media queries for layout changes
  • Check readability on mobile
  • Test buttons and menus on small screens
Design Tip: Always test important pages on mobile before publishing.
Try It Yourself

Practice Responsive Web Design

Edit media query and resize your browser to see the layout change.

HTML + CSS Code Edit and run
Output Preview Browser result
Practice Task: Add one more card, change breakpoint to 900px and reduce hero heading font-size on mobile.
Common Mistakes

Mistakes Students Should Avoid

Responsive design requires planning, testing and flexible layout choices.

Wrong Habits

  • Forgetting viewport meta tag
  • Using fixed width for main layout
  • Not making images flexible
  • Using desktop design only
  • Not testing on mobile screen

Correct Habits

  • Add viewport meta tag
  • Use width:100% and max-width
  • Use max-width:100% for images
  • Use media queries for layout changes
  • Test readability, spacing and buttons on mobile
Remember: A website is not complete until it works smoothly on mobile.
Quick Quiz

Test Your Understanding

Select the correct answers and check your score.

1. Responsive web design means:

Responsive design makes layout adapt to different devices and screen sizes.

2. Which meta tag is important for mobile-friendly pages?

The viewport meta tag is essential for mobile-friendly display.

3. Which CSS rule applies styles based on screen size?

@media is used for CSS media queries.

4. Which CSS is good for responsive images?

max-width:100%; height:auto; helps images scale properly.

5. Mobile-first design means:

Mobile-first means designing for small screens first and enhancing for larger screens.
Quick Revision

Remember These Points

Revise these before moving to Chapter 22.

Responsive Design

It makes webpages adjust to mobile, tablet and desktop screens.

Viewport

The viewport meta tag helps pages display properly on mobile.

Fluid Layout

Flexible width and max-width help layouts adapt.

Media Query

@media applies different CSS at different screen sizes.

Flexible Images

Use max-width:100%; height:auto; for responsive images.

Mobile First

Design for small screens first, then enhance for larger screens.