Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Mobile-friendly Design Basics
📖 Scenario: You are creating a simple webpage for a local bakery. Many customers visit the site using their phones. You want to make sure the page looks good and works well on small screens.
🎯 Goal: Build a basic HTML page with mobile-friendly design features. You will add the necessary meta tag, use responsive layout techniques, and ensure text and images adjust properly on mobile devices.
📋 What You'll Learn
Add the viewport meta tag for mobile scaling
Use a flexible container with CSS for layout
Include an image that scales with screen size
Use readable font sizes for mobile screens
💡 Why This Matters
🌍 Real World
Mobile-friendly design ensures websites look good and work well on phones and tablets, improving user experience and engagement.
💼 Career
Web designers and SEO specialists use mobile-friendly techniques to increase site traffic and meet search engine ranking criteria.
Progress0 / 4 steps
1
Add the viewport meta tag
Create a basic HTML skeleton with <!DOCTYPE html>, <html lang="en">, <head>, and <body> tags. Inside the <head>, add a <meta> tag with name="viewport" and content="width=device-width, initial-scale=1.0" to enable mobile scaling.
SEO Fundamentals
Hint
The viewport meta tag tells the browser how to adjust the page size on mobile devices.
2
Create a flexible container with CSS
Inside the <body>, add a <div> with class="container". In the <head>, add a <style> block that sets .container to use max-width: 600px;, margin: auto;, and padding: 1rem; for a centered, responsive layout.
SEO Fundamentals
Hint
The container centers content and limits width for better reading on phones.
3
Add a responsive image
Inside the <div class="container">, add an <img> tag with src="bread.jpg" and alt="Fresh bread". In the <style> block, add CSS to make images inside .container have max-width: 100% and height: auto so they scale on small screens.
SEO Fundamentals
Hint
Responsive images adjust their size to fit the screen width.
4
Set readable font size for mobile
In the <style> block, add CSS to set the body font size to 1.125rem (about 18px) for better readability on small screens.
SEO Fundamentals
Hint
Larger font sizes improve readability on small screens.
Practice
(1/5)
1. What is the main purpose of mobile-friendly design in websites?
easy
A. To make websites only work on desktop computers
B. To add more images to the website
C. To increase the website's loading time
D. To make websites easy to use on phones and tablets
Solution
Step 1: Understand mobile-friendly design goal
Mobile-friendly design aims to improve user experience on smaller screens like phones and tablets.
Step 2: Compare options to the goal
Only To make websites easy to use on phones and tablets matches this goal by focusing on ease of use on mobile devices.
Final Answer:
To make websites easy to use on phones and tablets -> Option D
Quick Check:
Mobile-friendly = easy use on phones/tablets [OK]
Hint: Mobile-friendly means easy use on phones and tablets [OK]
Common Mistakes:
Thinking mobile-friendly means adding more images
Believing it slows down the site intentionally
Assuming it only targets desktop users
2. Which CSS technique is commonly used to make a website adapt to different screen sizes?
easy
A. CSS media queries
B. CSS floats
C. CSS animations
D. CSS shadows
Solution
Step 1: Identify CSS techniques for responsive design
Responsive design uses CSS media queries to apply styles based on screen size.
Step 2: Match options to responsive technique
Only CSS media queries allow adapting layout for different devices.
Final Answer:
CSS media queries -> Option A
Quick Check:
Responsive design uses media queries [OK]
Hint: Media queries adjust styles by screen size [OK]
Common Mistakes:
Confusing floats with responsive layout
Thinking animations control layout
Believing shadows affect screen adaptation
3. Consider a website using this CSS snippet:
@media (max-width: 600px) { body { background-color: lightblue; } }
What happens when you view the site on a phone with screen width 500px?
medium
A. The background color stays the default
B. The background color changes to lightblue
C. The background color changes to darkblue
D. The site stops loading
Solution
Step 1: Understand the media query condition
The CSS applies styles when screen width is 600px or less.
Step 2: Check device screen width against condition
Phone screen is 500px, which is less than 600px, so styles apply.
Final Answer:
The background color changes to lightblue -> Option B
Quick Check:
Screen ≤ 600px triggers lightblue background [OK]
Hint: Check if device width meets media query condition [OK]
Common Mistakes:
Ignoring the max-width condition
Assuming default color always shows
Thinking site will crash on small screens
4. A developer wrote this CSS but the mobile layout is not working: