You've completed the lesson!
You now know how to structure web pages with HTML!
In this interactive lesson, you'll learn HTML by building your own personal profile page! You'll add headings, paragraphs, lists, links, and images - all the building blocks of web pages.
How it works: Type HTML code directly into the editors, click "Run Code" to see your page come to life, and check your answers to unlock the next exercise!
HTML stands for HyperText Markup Language. It's the skeleton of every website - it tells the browser what content to show and how to structure it.
Every single website you've ever visited - from Google to YouTube to your favorite game sites - is built with HTML. It's literally the foundation of the entire internet!
Think of building a house:
Without HTML, you can't have a website - just like you can't decorate a house that hasn't been built yet!
Let's break down this fancy name:
In simple terms: HTML is a way to write text with special instructions that tell browsers how to display it and connect it to other pages.
When you visit a website, here's what happens behind the scenes:
Amazing fact: Your browser is constantly converting HTML code into visual pages millions of times per day. Every webpage you see is HTML being interpreted in real-time!
HTML uses tags to mark up content. Think of tags as instructions that tell the browser "this is a heading" or "this is a paragraph".
Tags are like labels or instructions wrapped around your content. They tell the browser exactly how to treat each piece of information.
Real-world analogy: Think of a package delivery:
Without the labels, the delivery person wouldn't know how to handle the package!
<h1> - Starts an element
Your text or other elements
</h1> - Ends the element
Why do we need BOTH opening and closing tags?
The opening tag tells the browser where an element starts, and the closing tag tells it where the element ends. Without both, the browser wouldn't know what content belongs to that element!
Example:
<p>This is a paragraph</p>
<p> = Opening tag (starts the paragraph)This is a paragraph = Content (what's inside)</p> = Closing tag (ends the paragraph) - notice the forward slash /⚠️ Important: The closing tag MUST have a forward slash (/) before the tag name. Without it, the browser thinks it's another opening tag!
What happens if you forget the closing tag?
The browser will keep treating everything after the opening tag as part of that element, which can mess up your entire page layout!
What are attributes?
Attributes provide extra information about an element. They go inside the opening tag and follow this pattern:
<tag attributeName="value">content</tag>
Example with a link:
<a href="https://google.com">Click here</a>
href = Attribute name (tells WHERE the link goes)"https://google.com" = Attribute value (the actual URL)Think of HTML tags like labeled containers:
<h1> = "This box contains a heading")</h1> = "End of heading box")Just like you can't stack things in an open box without a bottom, you need both tags to properly contain your content!
What is nesting?
You can put HTML elements INSIDE other HTML elements. This is called nesting.
Example:
<div>
<h1>My Title</h1>
<p>This paragraph is inside the div</p>
</div>
Rules for nesting:
<div><p>Text</div></p> ❌<div><p>Text</p></div> ✅Mistake #1: Forgetting the Closing Tag
<h1>My Heading
<p>My paragraph</p>
❌ The <h1> was never closed! This will make everything after it part of the heading.
✅ Fix: <h1>My Heading</h1>
Mistake #2: Forgetting the Forward Slash in Closing Tags
<p>Hello<p>
❌ The second <p> should be </p> with a forward slash!
✅ Fix: <p>Hello</p>
Mistake #3: Mixing Up the Order (Wrong Nesting)
<div><p>Text</div></p>
❌ The <p> starts inside the <div>, but closes outside it!
✅ Fix: <div><p>Text</p></div>
Mistake #4: Forgetting Quotes Around Attributes
<img src=photo.jpg>
❌ The filename needs to be in quotes!
✅ Fix: <img src="photo.jpg">
Mistake #5: Using the Wrong Tag Name in Closing Tag
<h1>Title</h2>
❌ Started with <h1> but closed with </h2> - they must match!
✅ Fix: <h1>Title</h1>
Don't worry if your code doesn't work the first time - this happens to ALL programmers, even experts! Here's how to fix it:
Step 1: Check Your Tags Match
<tag> needs a </tag>Step 2: Look for the Forward Slash /
/ before the tag name</p> not <p>Step 3: Check Your Nesting
Step 4: Look for Missing Quotes
src="..."Pro Tip: If you're stuck, try commenting out parts of your code to find which line is causing the problem!
1. Use Indentation (Spacing)
This makes your code WAY easier to read:
<div>
<h1>Title</h1>
<p>Paragraph</p>
</div>
Notice how the inner tags are indented? This shows they're inside the <div>!
2. Use Meaningful Tag Names
<h1> for your main title (only use ONE per page!)<h2> for section headings<p> for paragraphs of text3. Add Comments to Remember What You Did
<!-- This is a comment - the browser ignores it -->
<h1>My Website</h1>
<!-- Main content section below -->
<p>Welcome to my site!</p>
Comments help you (and others) understand your code later!
Here's what you'll do:
💡 Important Tips:
Goal: Create a heading and a paragraph about yourself.
The <h1> Tag (Heading 1):
<h1>Your heading text here</h1><h1> and closing </h1> tags/) before h1The <p> Tag (Paragraph):
<p>Your paragraph text here</p><p> and closing </p> tags📝 Step-by-Step Instructions:
<h1> to start your heading</h1> to close the heading (don't forget the /!)<p> to start your paragraph</p> to close the paragraph✅ Complete Example:
<h1>Jane Smith</h1>
<p>I'm a student learning web development!</p>
Goal: Use different heading sizes and create multiple paragraphs.
Heading Hierarchy (6 levels):
<h1> - Biggest heading (use once per page for the main title)<h2> - Second level (for major sections)<h3> - Third level (for subsections)<h4>, <h5>, <h6> - Smaller headings (less common)Why use different heading levels?
Think of headings like an outline for an essay:
<h1> is your essay title<h2> are your main section headings<h3> are subsections within those sectionsMultiple Paragraphs:
You can have as many <p> tags as you want! Each one creates a new paragraph with spacing.
<p>First paragraph</p>
<p>Second paragraph</p>
<p>Third paragraph</p>
📝 What to do:
<h1> for your name (main title)<h2> to create section headings like "About Me" or "My Interests"<h2>, write at least one paragraphGoal: Create a list of your hobbies and add a link.
Creating Lists - Two Tags Working Together:
Lists need TWO types of tags that work as a team:
<ul> = "Unordered List" (the container for the whole list)<li> = "List Item" (each individual bullet point)How it works:
<ul> <!-- Start the list container -->
<li>First item</li> <!-- First bullet point -->
<li>Second item</li> <!-- Second bullet point -->
<li>Third item</li> <!-- Third bullet point -->
</ul> <!-- Close the list container -->
⚠️ Important:
<li> tags must be INSIDE the <ul> tags (this is nesting!)<li> needs its own closing </li> tag<li>Creating Links - Using Attributes:
Links use the <a> tag ("a" stands for "anchor") with a special href attribute:
Anatomy of a Link:
<a href="https://github.com">Click here</a>
<a = Start of the link taghref="https://github.com" = Attribute that tells WHERE to go (must have quotes!)> = End of opening tagClick here = The clickable text that users see</a> = Closing tag📝 Step-by-Step for Lists:
<ul> to start the list container<li></li> to close that list item</ul> to close the list container📝 Step-by-Step for Links:
<a href="https://github.com)"> to close the opening tag</a> to close the link<li> items!Goal: Add an image to your profile page.
The <img> Tag - A Special Self-Closing Tag:
Unlike other tags, <img> doesn't have a separate closing tag! It's self-closing because images don't contain content - they ARE the content.
Anatomy of an Image Tag:
<img src="url-to-image.jpg" alt="Description of image">
Required Attributes (you MUST include both):
src = "Source" - where the image is located (URL or file path)alt = "Alternative text" - describes the image for people who can't see itWhy is alt important?
Breaking Down the Image Tag:
<img src="https://via.placeholder.com/200" alt="Profile Picture">
<img = Start of image tagsrc="https://via.placeholder.com/200" = Where the image comes fromalt="Profile Picture" = Description of the image> = End of tag (no </img> needed!)📝 Step-by-Step:
<img src="" alt=""> to close the tag✅ Common Mistakes to Avoid:
<img src="url"></img> - Don't add a closing tag!<img src=url alt=text> - Must have quotes around attribute values!<img src="url" alt="text"> - Correct!src attribute is the image URLalt describes the image for accessibility<img> doesn't have a closing tag - it's self-closing!Goal: Learn to organize data using HTML tables.
Tables - Multiple Tags Working Together:
Tables are more complex because they need FOUR different tags working as a team:
<table> = The container for the entire table<tr> = "Table Row" - creates each horizontal row<th> = "Table Header" - cells in the header row (bold and centered)<td> = "Table Data" - regular cells with dataHow Tables Are Structured (Like a Grid):
Think of a table like a spreadsheet:
<table border="1"> <!-- Start table, border makes it visible -->
<tr> <!-- First row (header row) -->
<th>Name</th> <!-- First column header -->
<th>Age</th> <!-- Second column header -->
</tr> <!-- Close first row -->
<tr> <!-- Second row (data row) -->
<td>Jane</td> <!-- First column data -->
<td>25</td> <!-- Second column data -->
</tr> <!-- Close second row -->
</table> <!-- Close table -->
Understanding the Nesting:
<table> wraps everything<tr> must be inside the <table><th> or <td> must be inside a <tr>What's the border="1" attribute?
This is an attribute that adds visible borders to your table so you can see the cells. Without it, the table would be invisible!
📝 Step-by-Step to Build a Table:
<table border="1"> to start the table<tr> to start the first row (header row)<th>Header Text</th></tr> to close the header row<tr> to start a data row<td>Data</td></tr> to close the data row</table> to close the table✅ Key Rule: All cells in a row should have the same number of <th> or <td> elements, or your table will look broken!
<table> wraps the entire table<tr> creates each row<th> creates header cells (bold and centered)<td> creates regular data cellsGoal: Build an interactive form to collect user input.
Forms - Making Interactive Websites:
Forms let users type information and send it to a website. Think of them like paper forms, but digital!
The Tags You'll Need:
<form> = Container for all form elements<label> = Text label that describes an input<input> = Where users type information (self-closing!)<textarea> = Multi-line text input<button> = Clickable submit buttonUnderstanding Labels and IDs:
Labels and inputs work together using matching IDs:
<label for="userName">Name:</label>
<input type="text" id="userName">
for="userName" matches the input's id="userName"Different Input Types:
type="text" = Regular text inputtype="email" = Email input (validates email format)type="password" = Password input (hides characters)What's placeholder?
The placeholder attribute shows hint text inside an input:
<input type="text" placeholder="Enter your name">
This gray text disappears when the user starts typing!
The <br> Tag - Another Self-Closing Tag:
<br> creates a line break (like pressing Enter). It's self-closing, so no </br> needed!
Complete Form Example with Explanation:
<form> <!-- Start form -->
<label for="name">Name:</label> <!-- Label for name input -->
<br> <!-- Line break -->
<input type="text" id="name" placeholder="Your name"> <!-- Text input -->
<br><br> <!-- Two line breaks for spacing -->
<label for="email">Email:</label> <!-- Label for email -->
<br>
<input type="email" id="email" placeholder="you@email.com"> <!-- Email input -->
<br><br>
<label for="message">Message:</label> <!-- Label for message -->
<br>
<textarea id="message" rows="4" placeholder="Your message"></textarea> <!-- Text area -->
<br><br>
<button type="submit">Send</button> <!-- Submit button -->
</form> <!-- Close form -->
📝 Step-by-Step:
<form> to start the form container<label for="uniqueId">Label Text</label><br> for a line breakid="uniqueId"<br><br> for spacing<button type="submit"> at the end</form> to close the form⚠️ Important:
<input> is self-closing - no </input> needed<textarea> DOES need a closing tag: </textarea>for attribute in labels must match an id in inputs<form> wraps all form elements<label for="id"> labels inputs (for attribute matches input id)<input type="text"> creates text input<input type="email"> creates email input<textarea> creates multi-line text input<button type="submit"> creates submit buttonFinal Challenge: Combine everything you've learned to create a complete, professional profile page!
Putting It All Together:
This exercise tests everything you've learned! You'll use:
<h1> and <h2> - Headings for structure<p> - Paragraphs for descriptions<ul> and <li> - Lists for hobbies/skills<a href=""> - Links to your profiles<img src="" alt=""> - Your profile picture<table> with <tr>, <th>, <td> - Data in a table<form> with <input> and <button> - Contact form📋 Checklist - Your Page Must Include:
<h1> heading (your name)<h2> section headings<p> paragraphs<img> tag (profile picture)<ul> list with at least 3 <li> items<table> with headers and at least 2 data rows<form> with at least 2 inputs and a button<a> link💡 Tips for Success:
<img>, <br>, <input>)✅ Example Structure:
<h1>Your Name</h1>
<img src="url" alt="description">
<h2>About Me</h2>
<p>Your description...</p>
<h2>My Skills</h2>
<ul>
<li>Skill 1</li>
<li>Skill 2</li>
</ul>
<h2>Experience</h2>
<table border="1">
<tr>
<th>Skill</th>
<th>Level</th>
</tr>
<tr>
<td>HTML</td>
<td>Learning</td>
</tr>
</table>
<h2>Contact</h2>
<form>
<label for="email">Email:</label><br>
<input type="email" id="email"><br><br>
<button type="submit">Send</button>
</form>
<p><a href="url">Link text</a></p>
<h1>, <h2>, <p>, <ul>, <img>, <table>, <form>, and <a>