SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
Lesson 28 of 30

HTML Responsive

2 min read · Free · No login needed

Responsive design means one website that looks good on every screen — a phone, a tablet, a laptop, a TV. Today more than half of all web traffic comes from phones, so a page that only works on a desktop is a page that loses half its visitors.

Step 1: the viewport tag

Add <meta name="viewport" content="width=device-width, initial-scale=1.0"> to the head. Without it, phones pretend to be 980 pixels wide and shrink your page to fit — everything becomes tiny.

Step 2: flexible images

Set images to max-width: 100%; height: auto; in CSS. The image then shrinks to fit a narrow screen instead of overflowing and forcing a sideways scroll. Never use a fixed pixel width on an image that must work on phones.

Step 3: media queries

A media query applies CSS only when the screen is a certain size. For example: @media (max-width: 600px) { .sidebar { display: none; } } hides the sidebar on phones, where there is no room for it. You write the desktop layout first, then add queries that adjust it for smaller screens — or the other way round, starting mobile-first.

Test on a real phone

Resize your browser window to check the layout, but also open the page on a real phone. Touch targets (buttons, links) need to be big enough for a finger — at least 44 pixels tall — and text must stay readable without pinching to zoom.

Tip: In Chrome, press F12 and click the phone icon (top-left of the developer panel) to see your page as a phone would show it, in many screen sizes.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Responsive</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
img { max-width: 100%; height: auto; }
@media (max-width: 600px) {
  .sidebar { display: none; }
}
</style>
</head>
<body>

<h1>Responsive Page</h1>
<img src="photo.jpg" alt="A photo that shrinks on small screens">
<div class="sidebar">Sidebar — hidden on phones.</div>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Responsive
Try it yourself: copy the code above into a file named test.html, open it in your browser, and change the text to see what happens. That is how you learn — by changing things and watching the result.
Get certified — just ₹10

Finish all 30 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test
Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

AI & ML with Azure AI, AWS AI & Generative AI
₹10,000
View
AI Power Skills in 2 Days | Learn AI Text, Image, Video and Voice Tools
View
Website Design & Development Workshop 2026
₹299
View
Browse all courses
HTML — Lessons
1. HTML Introduction 2. HTML Editors 3. HTML Basic 4. HTML Elements 5. HTML Attributes 6. HTML Headings 7. HTML Paragraphs 8. HTML Styles 9. HTML Formatting 10. HTML Comments 11. HTML Colors 12. HTML CSS 13. HTML Links 14. HTML Images 15. HTML Favicon 16. HTML Page Title 17. HTML Tables 18. HTML Lists 19. HTML Block and Inline Elements 20. HTML Div 21. HTML Classes 22. HTML Id 23. HTML Iframes 24. HTML JavaScript 25. HTML File Paths 26. HTML Head 27. HTML Layout 28. HTML Responsive 29. HTML Semantics 30. HTML Forms
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🛡️ 7-Day Money-Back Guarantee
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Download karne ke liye login karo. Login ke baad yahi page pe rahoge!

Naya ho? Register karo →