Practice and reinforce the concepts from Lesson 2
In this activity, you'll:
Total time: 45-60 minutes
What you'll do: Open the project and familiarize yourself with the interface Time: 5 minutes
index.html
tip Click the "Open in New Tab" button in the preview panel to see your webpage in a full browser tab - this makes it easier to see your changes!
:warning: Important: Before You Start DO NOT DELETE any existing files in the template:
- Package files
- Configuration files
- Any files you didn't create
ONLY EDIT the
index.html
file for this activity.
Time: 5 minutes to read
HTML uses "tags" to mark up content. Tags are written with angle brackets < >
:
<tagname>content</tagname>
- Most tags come in pairs (opening and closing)<tagname />
- Some tags are self-closingTag | Purpose | Example |
---|---|---|
<h1> to <h6> |
Headings (h1 is biggest) | <h1>My Title</h1> |
<p> |
Paragraphs | <p>Some text</p> |
<ol> |
Ordered lists (1, 2, 3...) | <ol><li>First</li></ol> |
<ul> |
Unordered lists (bullets) | <ul><li>Item</li></ul> |
<li> |
List items | <li>List item</li> |
<a> |
Links | <a href="url">Click me</a> |
{/* */} |
Comments (hidden) | {/* Note to self */} |
What you'll learn: Every HTML page has the same basic structure Time: 3 minutes
Look at your index.html
file. You'll see:
<!DOCTYPE html>
<html>
<head>
<title>My first HTML exercise</title>
</head>
<body>
{/* Your content goes here */}
</body>
</html>
Explanation:
<!DOCTYPE html>
- Tells browser this is HTML5<html>
- Contains everything<head>
- Information about the page (not visible to users)<title>
- What appears in browser tab<body>
- All visible content goes hereWhat you'll do: Change what appears in the browser tab Time: 2 minutes
<title>My first HTML exercise</title>
<title>My Monthly Agenda</title>
tip StackBlitz auto-saves your work, but it's good practice to save manually!
What you'll do: Add the biggest heading to your page Time: 2 minutes
<body>
section in your code<body>
and </body>
, add this line:
<h1>My Monthly Agenda</h1>
What you'll learn: There are two types of lists Time: 3 minutes
Ordered Lists (<ol>
) - Numbered lists (1, 2, 3...)
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Unordered Lists (<ul>
) - Bullet point lists
<ul>
<li>First bullet</li>
<li>Second bullet</li>
</ul>
tip Lists can be nested! You can put a list inside another list item to create sub-categories.
What you'll do: Build the main structure with months Time: 3 minutes
After your <h1>
heading, add this ordered list:
<ol>
<li>November</li>
<li>December</li>
</ol>
Save and check your preview. You should see:
What you'll do: Create subcategories using nested lists Time: 3 minutes
Replace your November line with this expanded version:
<li>November
<ul>
<li>Goals</li>
<li>To-dos</li>
<li>Events</li>
</ul>
</li>
What's happening here:
<ul>
) with bullet pointstip Make sure to properly indent your nested lists - it helps you see the structure clearly!
What you'll do: Create another level of nesting Time: 3 minutes
Expand your Goals section like this:
<li>Goals
<ul>
<li>Lose 1kg of weight</li>
<li>Walk a total of 100,000 km</li>
</ul>
</li>
Save and check - you now have a third level of nesting!
What you'll do: Add items under To-dos and Events Time: 5 minutes
<li>November
<ul>
<li>Goals
<ul>
<li>Lose 1kg of weight</li>
<li>Walk a total of 100,000 km</li>
</ul>
</li>
<li>To-dos
<ul>
<li>Adopt a cat</li>
</ul>
</li>
<li>Events
<ul>
<li>Telebort class weekly at Sat/5pm</li>
<li>Family gathering on the 24th</li>
</ul>
</li>
</ul>
</li>
tip Common Challenge If your lists don't look right, check that:
<li>
has a closing </li>
<ul>
has a closing </ul>
What you'll do: Create the same structure for December Time: 5 minutes
Now add the December section with the same pattern:
<li>December
<ul>
<li>Goals
<ul>
<li>Try 5 new restaurants</li>
</ul>
</li>
<li>To-dos
<ul>
<li>Feed cat</li>
<li>Adopt another cat</li>
</ul>
</li>
<li>Events
<ul>
<li>Outing with friends on the 20th</li>
<li>Cousin birthday on the 27th</li>
</ul>
</li>
</ul>
</li>
This goes right after your November </li>
closing tag
What you should have: Here's what your complete <body>
section should look like:
Time: 2 minutes to verify
<body>
<h1>My Monthly Agenda</h1>
<ol>
<li>November
<ul>
<li>Goals
<ul>
<li>Lose 1kg of weight</li>
<li>Walk a total of 100,000 km</li>
</ul>
</li>
<li>To-dos
<ul>
<li>Adopt a cat</li>
</ul>
</li>
<li>Events
<ul>
<li>Telebort class weekly at Sat/5pm</li>
<li>Family gathering on the 24th</li>
</ul>
</li>
</ul>
</li>
<li>December
<ul>
<li>Goals
<ul>
<li>Try 5 new restaurants</li>
</ul>
</li>
<li>To-dos
<ul>
<li>Feed cat</li>
<li>Adopt another cat</li>
</ul>
</li>
<li>Events
<ul>
<li>Outing with friends on the 20th</li>
<li>Cousin birthday on the 27th</li>
</ul>
</li>
</ul>
</li>
</ol>
</body>
What you'll learn: How to create clickable links Time: 3 minutes
Add this anywhere in your page (perhaps after the heading):
<p>Watch HTML tutorials on <a href="https://www.youtube.com/">YouTube</a></p>
How it works:
<p>
creates a paragraph<a href="URL">
creates a clickable link<a>
and </a>
is what users click ontip
Links open in the same tab by default. To open in a new tab, add target="_blank"
to your link:
<a href="https://www.youtube.com/" target="_blank">YouTube</a>
What you'll learn: How to add notes that don't appear on the page Time: 2 minutes
Add comments to organize your code:
{/* This is the main heading */}
<h1>My Monthly Agenda</h1>
{/* November agenda section */}
<li>November
{/* ... rest of November code ... */}
</li>
{/* December agenda section */}
<li>December
{/* ... rest of December code ... */}
</li>
Comments help you and others understand your code later!
What you should see: Your page should display exactly like the provided screenshot: Time: 2 minutes
tip Final Check
Time: 3 minutes
When you have completed your "Introduction to HTML" project:
:information_source: Important Make sure to click "Fork and Commit" before submitting - this saves your work!
When you have completed your "Introduction to HTML" project, submit it using the link below:
:warning: Submission Required Submit Your Project Here
You'll need:
- Your StackBlitz project URL
- Your name
- Any questions or feedback
My lists don't look right:
<li>
tags are inside <ul>
or <ol>
tagsThe preview isn't updating:
My browser tab still shows the old title:
<title>
tag, not the <h1>
tagtip Still Stuck?
Great job completing your first HTML project! You've learned:
Next up: You'll learn how to make your webpage look beautiful with CSS!