CHAPTER 78

CSS Responsive Web Design

Learn the principles required to create websites that work across desktop, tablet and mobile screens.

01. What is CSS Responsive Web Design?

Responsive design allows a website to adapt to different screen sizes.
Flexible layouts, images and media queries are key parts of responsive design.
Mobile users should receive a comfortable and usable interface.

02. Syntax

img { max-width: 100%; height: auto; } .container { width: 100%; max-width: 1200px; margin: auto; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>

.container {
    width: 100%;
    max-width: 1100px;
    margin: auto;
    padding: 20px;
}

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

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

@media(max-width:800px) {

    .cards {
        grid-template-columns: 1fr 1fr;
    }

}

@media(max-width:500px) {

    .cards {
        grid-template-columns: 1fr;
    }

}

</style>
</head>
<body>

<div class="container">

    <div class="cards">

        <div>HTML</div>
        <div>CSS</div>
        <div>JavaScript</div>

    </div>

</div>

</body>
</html>

04. Important Points

✓ Use flexible widths.
✓ Use max-width for containers.
✓ Make images responsive.
✓ Use media queries where content requires them.
✓ Test on multiple screen sizes.

05. Common Mistakes

⚠ Using fixed widths everywhere.
⚠ Ignoring mobile navigation.
⚠ Allowing horizontal page overflow.
⚠ Testing only on one device.

06. Real World Use

Responsive design is essential for modern business websites, education portals, e-commerce sites and web applications.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Build a Responsive Course Section

Create six course cards that display three columns on desktop, two on tablet and one on mobile.