CSS: Responsive Design

Learn how to create web pages that adapt to different screen sizes and devices.

Responsive Design Techniques

CSS provides several techniques to make web pages responsive:

Example: Media Queries

/* Example */
body {
    font-size: 16px;
}
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
}
@media (max-width: 480px) {
    body {
        font-size: 12px;
    }
}
        

This example adjusts the font size based on screen width.

Example: Responsive Images

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

This example ensures images scale proportionally within their container.

Practice

Try experimenting with responsive design techniques:

Continue Learning

Quick Check

Which CSS feature lets you apply styles based on screen size?