Academy / Intermediate Level: HTML and CSS

Intermediate Level Practice: HTML and CSS

Part 3: Responsive Design Practice

Exercise: Create a Responsive Navigation Menu

In this exercise, you'll create a simple responsive navigation menu that turns into a hamburger menu on smaller screens.

Task:

  1. Create a horizontal navigation bar for large screens.
  2. Use media queries to turn it into a vertical menu (or hamburger icon) for mobile screens.
  3. Style the menu with hover and focus states.

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Nav</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<ul class="nav-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</body>
</html>

CSS:

Style the navigation bar for large and small screens using media queries.