Imagine you're helping a friend open a new restaurant. They need a menu to show their customers, but instead of using paper, we're going to create it for their website! Think of it like building a digital version of those menus you see at restaurants.
Before we jump in, let's understand why this project is great for beginners like you:
By the end of this tutorial, you'll have built:
Don't worry if you're new to HTML! We'll explain everything step by step, just like following a recipe. If you get stuck, that's totally normal - even experienced developers use Google and ask questions all the time!
Before a chef starts cooking, they set up their kitchen with all the tools they need. Similarly, we need to set up our "digital kitchen" - our workspace where we'll build our menu!
Think of a project folder like a recipe box where you keep all your ingredients and instructions together. Here's how to make one:
A text editor is like your chef's knife - it's the main tool you'll use to create your HTML. We recommend Visual Studio Code (VS Code) because:
code.visualstudio.com
Now, let's create the file where we'll write our menu:
We use "index.html" because it's like the front door of your website. When someone visits your website, the browser automatically looks for an "index.html" file first - just like how you'd look for the front door when visiting a restaurant!
Just like a building needs a strong foundation, our menu needs a basic HTML structure to build upon. Think of it as the blueprint for our digital restaurant menu.
Open your "index.html" file and add the following code:
<!DOCTYPE html>
This line tells the browser that this document is written in HTML5.
Next, add the following code:
<html lang="en">
This line starts your HTML document and specifies that the language is English.
Now, add the following code:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yummy Restaurant Menu</title>
</head>
Let's understand each line:
<head>
contains meta information about the document.<meta charset="UTF-8">
sets the character encoding to UTF-8, supporting various languages.<meta name="viewport" content="width=device-width, initial-scale=1.0">
ensures that the menu looks good on different devices and screen sizes.<title>
sets the title of the webpage, which appears in the browser tab.Finally, add the following code:
<body>
<header>
<h1>Yummy Restaurant</h1>
</header>
<main>
<!-- We'll put our menu here soon! -->
</main>
<footer>
<p>Ā© 2024 Yummy Restaurant</p>
</footer>
</body>
</html>
What are these for?
<body>
is where all the visible content goes (like text and images).<header>
is the top part of the page, like the restaurant's sign.<main>
is the main content area, where we'll put our menu items.<footer>
is the bottom part of the page, like the restaurant's business card.You should see "Yummy Restaurant" at the top of a mostly blank page. That's perfect! We'll add the delicious details in the next steps.
When you go to a restaurant, the menu is usually divided into sections like appetizers, main courses, and desserts. We're going to create these sections in our digital menu!
Let's add the appetizers section inside the <main>
tag:
<section id="appetizers">
<h2>Tasty Starters</h2>
<div class="menu-section">
<!-- We'll add appetizer items here -->
</div>
</section>
Understanding the new parts:
<section>
is like a different area in your restaurant, one for appetizers.id="appetizers"
is like putting a label on the section.<h2>
is the section title, like the heading in a paper menu.<div class="menu-section">
is a container for the menu items.Below the appetizers section, add the main courses section:
<section id="main-courses">
<h2>Main Dishes</h2>
<div class="menu-section">
<!-- We'll add main course items here -->
</div>
</section>
Understanding the new parts:
<section id="main-courses">
is the section for main dishes.<h2>
is the section title for main dishes.Below the main courses section, add the desserts section:
<section id="desserts">
<h2>Sweet Endings</h2>
<div class="menu-section">
<!-- We'll add dessert items here -->
</div>
</section>
Understanding the new parts:
<section id="desserts">
is the section for desserts.<h2>
is the section title for desserts.Save your file and refresh it in your web browser. You should now see the section titles for appetizers, main courses, and desserts.
Now comes the fun part - adding actual food items to our menu! Think of this like writing down all the dishes your restaurant serves, complete with descriptions and prices.
Inside the <div class="menu-section">
of the appetizers section, add the following code:
<div class="menu-item">
<h3>Crispy Mozzarella Sticks <span class="price">$7.99</span></h3>
<p class="description">
Golden-brown on the outside, melty on the inside. Served with our
special marinara sauce.
</p>
</div>
<div class="menu-item">
<h3>Garden Fresh Salad <span class="price">$6.99</span></h3>
<p class="description">
Crisp lettuce, cherry tomatoes, cucumbers, and carrots with your
choice of dressing.
</p>
</div>
Understanding the new parts:
<div class="menu-item">
is a container for each menu item.<h3>
is the name of the dish, with the price in a<span>
tag.<p class="description">
is the description of the dish.Inside the <div class="menu-section">
of the main courses section, add the following code:
<div class="menu-item">
<h3>Cheeseburger with Fries <span class="price">$12.99</span></h3>
<p class="description">
A juicy cheeseburger served with crispy fries and a side of ketchup.
</p>
</div>
<div class="menu-item">
<h3>Grilled Salmon with Vegetables <span class="price">$18.99</span></h3>
<p class="description">
Freshly grilled salmon served with a side of seasonal vegetables.
</p>
</div>
<div class="menu-item">
<h3>Chicken Alfredo Pasta <span class="price">$15.99</span></h3>
<p class="description">
Tender chicken breast in a creamy Alfredo sauce over fettuccine pasta.
</p>
</div>
Inside the <div class="menu-section">
of the desserts section, add the following code:
<div class="menu-item">
<h3>Chocolate Lava Cake <span class="price">$8.99</span></h3>
<p class="description">
Warm chocolate cake with a gooey center, served with vanilla ice cream.
</p>
</div>
<div class="menu-item">
<h3>Apple Pie <span class="price">$7.99</span></h3>
<p class="description">
Homemade apple pie with a flaky crust, served with whipped cream.
</p>
</div>
Save your file and refresh it in your web browser. You should now see all the menu items listed in their respective sections.
Right now, our menu has all the right information, but it might look a bit plain. Let's add some navigation links and basic styling to make it more user-friendly!
Add the following code right after your <header>
section:
<nav>
<ul>
<li><a href="#appetizers">Starters</a></li>
<li><a href="#main-courses">Main Dishes</a></li>
<li><a href="#desserts">Desserts</a></li>
</ul>
</nav>
Understanding the new parts:
<nav>
is used to define a set of navigation links.<ul>
is an unordered list, used to group the navigation links.<li>
is a list item, each containing a navigation link.<a href="#appetizers">
is a hyperlink that links to the appetizers section.Save your file and refresh it in your web browser. You should now see a navigation bar at the top of the page, and clicking the links should take you to the corresponding sections.
We're almost done! Just like a chef tastes their dishes before serving them, we need to test our menu to make sure everything works perfectly.
Let's add some information at the bottom of your menu (in the footer):
<footer>
<div class="restaurant-info">
<h3>Visit Us</h3>
<p>123 Tasty Street, Food City, FC 12345</p>
<p>Phone: (555) 123-4567</p>
<p>Open Daily: 11:00 AM - 10:00 PM</p>
</div>
<div class="social-media">
<p>Follow us on social media for daily specials!</p>
<p>@YummyRestaurant</p>
</div>
<p class="copyright">Ā© 2024 Yummy Restaurant. All rights reserved.</p>
</footer>
Here's the complete HTML code for your restaurant menu:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yummy Restaurant Menu</title>
</head>
<body>
<header>
<h1>Yummy Restaurant</h1>
</header>
<nav>
<ul>
<li><a href="#appetizers">Starters</a></li>
<li><a href="#main-courses">Main Dishes</a></li>
<li><a href="#desserts">Desserts</a></li>
</ul>
</nav>
<main>
<section id="appetizers">
<h2>Tasty Starters</h2>
<div class="menu-section">
<div class="menu-item">
<h3>Crispy Mozzarella Sticks <span class="price">$7.99</span></h3>
<p class="description">
Golden-brown on the outside, melty on the inside. Served with our
special marinara sauce.
</p>
</div>
<div class="menu-item">
<h3>Garden Fresh Salad <span class="price">$6.99</span></h3>
<p class="description">
Crisp lettuce, cherry tomatoes, cucumbers, and carrots with your
choice of dressing.
</p>
</div>
</div>
</section>
<section id="main-courses">
<h2>Main Dishes</h2>
<div class="menu-section">
<div class="menu-item">
<h3>Cheeseburger with Fries <span class="price">$12.99</span></h3>
<p class="description">
A juicy cheeseburger served with crispy fries and a side of ketchup.
</p>
</div>
<div class="menu-item">
<h3>Grilled Salmon with Vegetables <span class="price">$18.99</span></h3>
<p class="description">
Freshly grilled salmon served with a side of seasonal vegetables.
</p>
</div>
<div class="menu-item">
<h3>Chicken Alfredo Pasta <span class="price">$15.99</span></h3>
<p class="description">
Tender chicken breast in a creamy Alfredo sauce over fettuccine pasta.
</p>
</div>
</div>
</section>
<section id="desserts">
<h2>Sweet Endings</h2>
<div class="menu-section">
<div class="menu-item">
<h3>Chocolate Lava Cake <span class="price">$8.99</span></h3>
<p class="description">
Warm chocolate cake with a gooey center, served with vanilla ice cream.
</p>
</div>
<div class="menu-item">
<h3>Apple Pie <span class="price">$7.99</span></h3>
<p class="description">
Homemade apple pie with a flaky crust, served with whipped cream.
</p>
</div>
</div>
</section>
</main>
<footer>
<div class="restaurant-info">
<h3>Visit Us</h3>
<p>123 Tasty Street, Food City, FC 12345</p>
<p>Phone: (555) 123-4567</p>
<p>Open Daily: 11:00 AM - 10:00 PM</p>
</div>
<div class="social-media">
<p>Follow us on social media for daily specials!</p>
<p>@YummyRestaurant</p>
</div>
<p class="copyright">Ā© 2024 Yummy Restaurant. All rights reserved.</p>
</footer>
</body>
</html>
You should see the complete restaurant menu with all sections, items, and navigation links working correctly.
You've built your first complete web page! This menu isn't just a practice project - it's a real-world example of what you might create for an actual restaurant. You've learned:
Feel free to customize this menu further by:
Keep practicing and exploring HTML. The more you build, the more comfortable you'll become with creating amazing web content!