Most visitors in India use phones, so every page must work on small screens.
The three basics
- Viewport tag in the head:
<meta name="viewport" content="width=device-width, initial-scale=1">. - Flexible images:
img { max-width: 100%; height: auto; }so images never overflow. - Media queries in CSS to change the layout on small screens.
Responsive images
srcset lets the browser pick a smaller image for phones — faster loading and less data.
Example
Example — Responsive basics
HTML
<style>
img { max-width: 100%; height: auto; }
.cards { display: flex; gap: 10px; }
.card { flex: 1; background: #e0f2fe; padding: 12px; }
@media (max-width: 600px) {
.cards { flex-direction: column; }
}
</style>
<div class="cards">
<div class="card">Card 1</div>
<div class="card">Card 2</div>
<div class="card">Card 3</div>
</div>
<p>Make the window narrow — the cards stack on top of each other.</p>