Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Responsive Web Design Concepts

Lesson 13 of 34 in the free Web Technologies notes on Siksha Sarovar, written by Rohit Jangra.

Responsive Web Design Concepts

What is Responsive Web Design?

Responsive Web Design (RWD) is an approach where web pages render well on a variety of devices and screen sizes by using flexible grids, layouts, images, and CSS media queries.

The Viewport Meta Tag

Always include this in <head>:

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

Without it, mobile browsers zoom out to show the full desktop page.

CSS Media Queries

/* Base styles: mobile first */
body { font-size: 14px; }

/* Tablet */
@media (min-width: 768px) {
    body { font-size: 16px; }
    .container { max-width: 720px; }
}

/* Desktop */
@media (min-width: 1024px) {
    body { font-size: 18px; }
    .container { max-width: 960px; }
}

/* Large desktop */
@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

/* Landscape orientation */
@media (orientation: landscape) {
    nav { flex-direction: row; }
}

/* Print */
@media print {
    nav, footer { display: none; }
}

Responsive Images

<!-- Fluid image -->
<img src="photo.jpg" style="max-width: 100%; height: auto;" alt="...">

<!-- srcset for different resolutions -->
<img src="small.jpg"
     srcset="small.jpg 480w, medium.jpg 768w, large.jpg 1200w"
     sizes="(max-width: 480px) 100vw, (max-width: 768px) 50vw, 33vw"
     alt="Responsive image">

<!-- Picture element for art direction -->
<picture>
  <source media="(min-width: 768px)" srcset="desktop.jpg">
  <img src="mobile.jpg" alt="Hero image">
</picture>

Responsive Units

UnitDescription
%Percentage of parent
vw1% of viewport width
vh1% of viewport height
emRelative to font-size of element
remRelative to root font-size
frFraction unit (CSS Grid)

Mobile-First vs Desktop-First

ApproachStrategy
Mobile-firstStart with small screens, use min-width media queries to add features
Desktop-firstStart with large screens, use max-width to simplify for mobile

Mobile-first is the recommended approach.

Responsive Navigation Pattern

/* Mobile: hamburger menu */
.nav-links { display: none; }
.hamburger { display: block; }

@media (min-width: 768px) {
    .nav-links { display: flex; }
    .hamburger { display: none; }
}
Key Takeaway: Responsive design uses flexible grids, fluid images, and media queries to adapt layouts for any screen size. Always set the viewport meta tag and prefer a mobile-first approach.