Responsive Box with Media Queries
📖 Scenario: You are creating a simple webpage with a colored box. The box should change its background color depending on the screen size. This helps the webpage look good on phones, tablets, and desktops.
🎯 Goal: Build a webpage with a <div> box that is blue on small screens, green on medium screens, and orange on large screens using CSS media queries.
📋 What You'll Learn
Create a blue box with width 200px and height 200px by default
Use a media query to change the box background color to green when the screen width is at least 600px
Use another media query to change the box background color to orange when the screen width is at least 900px
Use semantic HTML and include a
<main> containerEnsure the CSS is responsive and uses media queries correctly
💡 Why This Matters
🌍 Real World
Media queries are essential for building websites that look good on all devices, from small phones to large desktop monitors.
💼 Career
Web developers use media queries daily to create responsive designs that improve user experience and accessibility.
Progress0 / 4 steps