Lesson 5.6 β Building Mobile Friendly Pages
π Creating Complete Webpages That Work Perfectly on Mobile, Tablet, Laptop, and Desktop Devices
π― Learning Objectives
After completing this lesson, students will be able to:
β Build Mobile-Friendly Webpages
β Apply Mobile First Design
β Use Media Queries
β Use Responsive Images
β Create Responsive Navigation
β Build Professional Responsive Layouts
β Create Real-World Webpages
π Introduction
So far we have learned:
β Responsive Design
β Mobile First Design
β Media Queries
β Responsive Images
β Responsive Navigation Bar
Now it is time to combine everything and build a complete:
π± Mobile Friendly Webpage
π€ What is a Mobile Friendly Page?
A Mobile Friendly Page is a webpage that:
β Fits all screen sizes
β Has readable text
β Has responsive images
β Has touch-friendly buttons
β Has proper navigation
β Does not require horizontal scrolling
π Characteristics of Mobile Friendly Websites
A good mobile-friendly website should have:
1οΈβ£ Responsive Layout
Automatically adjusts to screen size.
2οΈβ£ Responsive Images
Images resize automatically.
3οΈβ£ Easy Navigation
Menus should be easy to use.
4οΈβ£ Readable Text
Text should not be too small.
5οΈβ£ Touch-Friendly Buttons
Buttons should be easy to tap.
π― Example Layout
Desktop View
--------------------------------
LOGO
HOME ABOUT CONTACT
--------------------------------
WELCOME SECTION
--------------------------------
SERVICES
CARD 1 CARD 2 CARD 3
--------------------------------
FOOTER
--------------------------------
Mobile View
LOGO
HOME
ABOUT
CONTACT
WELCOME SECTION
CARD 1
CARD 2
CARD 3
FOOTER
π Step 1 β Create Project Structure
Create files:
index.html
style.css
π― Step 2 β Create Basic HTML
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Mobile Friendly Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
</body>
</html>
π€ What is Viewport Meta Tag?
Very important for responsive websites.
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
Without it:
β Mobile responsiveness may not work properly.
With it:
β Website adjusts correctly on mobile devices.
π― Step 3 β Create Navigation
Inside body:
<nav>
<h2>NextGen Dev Hub</h2>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Courses</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
π― Step 4 β Create Hero Section
<section class="hero">
<h1>
Learn Web Designing
</h1>
<p>
Create modern responsive websites.
</p>
<button>
Join Now
</button>
</section>
π― Step 5 β Create Services Section
<section class="services">
<div class="card">
<h3>HTML</h3>
<p>Website Structure</p>
</div>
<div class="card">
<h3>CSS</h3>
<p>Website Styling</p>
</div>
<div class="card">
<h3>JavaScript</h3>
<p>Website Interaction</p>
</div>
</section>
π― Step 6 β Create Footer
<footer>
Β© 2026 NextGen Dev Hub
</footer>
π Complete HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Mobile Friendly Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<h2>NextGen Dev Hub</h2>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Courses</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<section class="hero">
<h1>
Learn Web Designing
</h1>
<p>
Create modern responsive websites.
</p>
<button>
Join Now
</button>
</section>
<section class="services">
<div class="card">
<h3>HTML</h3>
<p>Website Structure</p>
</div>
<div class="card">
<h3>CSS</h3>
<p>Website Styling</p>
</div>
<div class="card">
<h3>JavaScript</h3>
<p>Website Interaction</p>
</div>
</section>
<footer>
Β© 2026 NextGen Dev Hub
</footer>
</body>
</html>
π¨ Step 7 β Style Body
body{
margin:0;
font-family:Arial;
background:#f5f5f5;
}
π¨ Step 8 β Style Navigation
nav{
display:flex;
justify-content:space-between;
align-items:center;
background:#0d6efd;
padding:15px 20px;
}
nav h2{
color:white;
}
nav ul{
display:flex;
gap:20px;
list-style:none;
}
nav a{
color:white;
text-decoration:none;
font-weight:bold;
}
π¨ Step 9 β Style Hero Section
.hero{
text-align:center;
padding:80px 20px;
background:white;
}
.hero h1{
font-size:40px;
color:#0d6efd;
}
.hero button{
padding:12px 25px;
background:#0d6efd;
color:white;
border:none;
border-radius:5px;
font-size:18px;
cursor:pointer;
}
π¨ Step 10 β Style Services Section
.services{
display:grid;
grid-template-columns:1fr 1fr 1fr;
gap:20px;
padding:40px;
}
.card{
background:white;
padding:20px;
text-align:center;
border-radius:10px;
box-shadow:0 0 10px lightgray;
}
π¨ Step 11 β Style Footer
footer{
background:#0d6efd;
color:white;
text-align:center;
padding:20px;
}
π― Step 12 β Add Media Query
This is the most important step.
@media (max-width:768px)
{
nav{
flex-direction:column;
}
nav ul{
flex-direction:column;
padding:0;
}
.hero h1{
font-size:28px;
}
.services{
grid-template-columns:1fr;
}
}
π€ What Happens Here?
Desktop:
HTML CSS JavaScript
Three cards in one row.
Mobile:
HTML
CSS
JavaScript
Cards move into one column.
π Complete CSS
body{
margin:0;
font-family:Arial;
background:#f5f5f5;
}
nav{
display:flex;
justify-content:space-between;
align-items:center;
background:#0d6efd;
padding:15px 20px;
}
nav h2{
color:white;
}
nav ul{
display:flex;
gap:20px;
list-style:none;
}
nav a{
color:white;
text-decoration:none;
font-weight:bold;
}
.hero{
text-align:center;
padding:80px 20px;
background:white;
}
.hero h1{
font-size:40px;
color:#0d6efd;
}
.hero button{
padding:12px 25px;
background:#0d6efd;
color:white;
border:none;
border-radius:5px;
font-size:18px;
}
.services{
display:grid;
grid-template-columns:1fr 1fr 1fr;
gap:20px;
padding:40px;
}
.card{
background:white;
padding:20px;
border-radius:10px;
text-align:center;
box-shadow:0 0 10px lightgray;
}
footer{
background:#0d6efd;
color:white;
text-align:center;
padding:20px;
}
@media (max-width:768px)
{
nav{
flex-direction:column;
}
nav ul{
flex-direction:column;
padding:0;
}
.hero h1{
font-size:28px;
}
.services{
grid-template-columns:1fr;
}
}
π― Expected Output
Desktop
β Horizontal Menu
β Large Heading
β Three Service Cards
Mobile
β Vertical Menu
β Smaller Heading
β Single Column Cards
β Easy Navigation
π« Real World Applications
Mobile-Friendly Pages are used in:
β College Websites
β Business Websites
β Portfolio Websites
β E-Commerce Websites
β LMS Platforms
β News Websites
β οΈ Common Beginner Mistakes
Mistake 1
Missing Viewport Tag
Wrong:
No viewport meta tag
Mistake 2
Using Fixed Width
Wrong:
width:1200px;
Use:
width:100%;
Mistake 3
No Media Query
Website may break on mobile.
Mistake 4
Very Small Buttons
Wrong:
padding:3px;
Better:
padding:12px 25px;
π Best Practices
β Always use viewport meta tag.
β Use responsive layouts.
β Use Flexbox and Grid.
β Use Media Queries.
β Test on mobile phones.
β Keep navigation simple.
π Mini Project β Responsive Student Information Page
Create a webpage containing:
Header
Student Name
About Section
Branch
College
Skills
Contact Button
Apply:
β Responsive Navigation
β Responsive Layout
β Media Queries
β Mobile-Friendly Design
π Practical Activity
Create a:
Polytechnic College Homepage
Include:
- Navigation Bar
- Hero Section
- Courses Section
- Contact Section
- Footer
Make it fully responsive.
π Assignment
Assignment 5.6
- What is a Mobile Friendly Page?
- Why is the viewport tag important?
- What is the role of Media Queries?
- Why should layouts be responsive?
- Create a responsive webpage.
- Create a responsive services section.
- Explain the importance of mobile-friendly websites.
π§ Quiz
Q1. Which HTML tag is important for responsive websites?
A. title
B. meta viewport
C. link
D. img
β Answer: B
Q2. Which CSS feature helps adapt layouts to screen size?
A. Border
B. Animation
C. Media Query
D. Font
β Answer: C
Q3. Which layout method is commonly used for responsive pages?
A. Flexbox
B. Grid
C. Both
D. Table
β Answer: C
Q4. Which device benefits most from mobile-friendly pages?
A. Smartphone
B. Tablet
C. Laptop
D. All Devices
β Answer: D
Q5. Responsive websites improve?
A. User Experience
B. Accessibility
C. Professional Appearance
D. All of These
β Answer: D
π Lesson Summary
β Mobile-Friendly Pages work properly on all screen sizes.
β Viewport meta tag is essential for responsiveness.
β Flexbox, Grid, and Media Queries help create responsive layouts.
β Mobile-friendly websites provide a better user experience.
β Every modern website should be responsive and mobile-friendly.