-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics
Responsive web design ensures that your website looks good on all devices—desktops, tablets, and mobile phones—by automatically adjusting layout, content size, and appearance based on screen size.
Provides better user experience
Improves SEO ranking (Google prioritizes mobile-friendly sites)
Works on any screen size (mobile, tablet, laptop, desktop)
Saves development time by using a single codebase
The first step in making a website responsive is setting the viewport.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Images should resize automatically based on screen size.
<img src="banner.jpg" alt="Banner" style="max-width:100%; height:auto;">
Avoid fixed pixel sizes. Use percentages or relative units.
<div style="width: 50%;">This takes half of the screen width</div>
Media queries in CSS allow you to apply styles based on screen size.
/* Default for desktop */
body {
background-color: lightblue;
}
/* For devices smaller than 768px */
@media only screen and (max-width: 768px) {
body {
background-color: lightgreen;
}
}
Flexbox makes it easy to create flexible layouts.
.container {
display: flex;
flex-wrap: wrap;
}
.box {
flex: 1 1 300px;
margin: 10px;
}
Use em
, %
, or vw
for scalable text sizes.
h1 {
font-size: 5vw; /* 5% of the viewport width */
}
Start with styles for mobile and add media queries for larger screens.
/* Mobile styles */
body {
font-size: 14px;
}
/* Tablets and up */
@media (min-width: 768px) {
body {
font-size: 16px;
}
}
Q1. Add a viewport meta tag to your HTML document.
Q2. Create an image that resizes based on screen width.
Q3. Build a layout using percentage-based width.
Q4. Use Flexbox to create a two-column layout that stacks on small screens.
Q5. Write a media query that changes the background color for screens smaller than 600px.
Q6. Design a heading with vw
units so it scales with the screen.
Q7. Make a <div>
take full width on mobile and 50% on desktop.
Q8. Create a mobile-first style sheet and override it for tablets.
Q9. Use max-width
and height: auto
to create responsive images.
Q10. Use media queries to hide an element on mobile view.
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics