Practice and reinforce the concepts from Lesson 5
<div> elements for structured layoutsTime: 2 minutes
stackblitz-starters-brpgud4g⚠️ IMPORTANT: Before You Start DO NOT DELETE the existing files in the template:
- Package files
- Any other files you didn't create
ONLY EDIT the necessary files (index.html and style.css)
In this activity, you will practice using HTML <div> elements to create structured layouts. You'll build a "My Dinner" webpage featuring nested divisions, CSS styling, and properly spaced elements.
Time: 2 minutes
Study the final result to understand what you're building:

tip Take a moment to identify the different divisions in the output:
Time: 5 minutes
index.html page in a new windowindex.html file, change the title of the document to My Dinnerstyle.css file and link it to the index.html filetip Finding Good Images
Time: 5 minutes
In your index.html file, under the <body>:
<div> with an id named title<div>, add:
<h1> tag with the content: My Dinner<p> tag with the content: These are the 3 types of food I eat during my dinnerIn your style.css file:
text-align: center;background-color: aqua;tip ID Selector Reminder Remember that ID selectors use the # symbol. For example:
#title {
/* your styles here */
}
Time: 7 minutes
In your index.html file, after the title div:
<div> with a class named dining-table<div>, create three child divisions:
<div class="red-plate"></div><div class="yellow-plate"></div><div class="green-plate"></div>In your style.css file:
| Class | CSS Properties |
|---|---|
.dining-table |
height: 300px;width: 500px;background-color: brown; |
.red-plate |
height: 200px;width: 200px;background-color: red; |
.yellow-plate |
height: 200px;width: 200px;background-color: yellow; |
.green-plate |
height: 200px;width: 200px;background-color: green; |
tip Nesting Structure Your HTML structure should look like this:
<div class="dining-table">
<div class="red-plate"></div>
<div class="yellow-plate"></div>
<div class="green-plate"></div>
</div>
Time: 5 minutes
In your index.html file:
<div class="red-plate">, add an <img> tag with your first food image<div class="yellow-plate">, add an <img> tag with your second food image<div class="green-plate">, add an <img> tag with your third food imageIn your style.css file:
<img> tags:
height: 60px;width: 60px;tip Image Paths If your images are in the assets folder, your img tags should look like:
<img src="assets/your-food-image.png" alt="Food description">
Always include alt text for accessibility!
Time: 8 minutes
In your style.css file:
Add padding to the title division:
#title {
padding: 20px;
/* keep your existing styles */
}
Center the dining table and use Flexbox for layout:
.dining-table {
margin: 50px auto;
padding: 30px;
display: flex; /* Modern Flexbox layout */
gap: 40px; /* CSS3 gap property for spacing */
justify-content: center;
/* keep your existing styles */
}
Make plates circular:
.red-plate, .yellow-plate, .green-plate {
border-radius: 50%; /* Creates circular plates */
/* keep your existing styles */
}
💡 Modern CSS Pattern We're using the CSS3
gapproperty instead of old-school margins. This is the modern way to add spacing in Flexbox layouts - cleaner code and better browser support (2021+)!Common Issues:
- Plates not appearing side by side? Make sure you added
display: flex;to.dining-table- Dining table not centered? Check that you have both
margin: 50px auto;and a defined width- Uneven spacing? Verify you're using
gap: 40px;(notmarginon individual plates)
CSS file not working
<link> tag is correctly formatted: <link rel="stylesheet" href="style.css">style.cssImages not displaying
assets/Layout looks different than expected
Time: 2 minutes
Before submitting, ensure:
ℹ️ Info Project Submission When you have completed your HTML Division project: