3-terrarium/1-intro-to-html/README.md
journey
title Your HTML Learning Journey
section Foundation
Create HTML file: 3: Student
Add DOCTYPE: 4: Student
Structure document: 5: Student
section Content
Add metadata: 4: Student
Include images: 5: Student
Organize layout: 5: Student
section Semantics
Use proper tags: 4: Student
Enhance accessibility: 5: Student
Build terrarium: 5: Student
Sketchnote by Tomomi Imura
HTML, or HyperText Markup Language, is the foundation of every website you've ever visited. Think of HTML as the skeleton that gives structure to web pages – it defines where content goes, how it's organized, and what each piece represents. While CSS will later "dress up" your HTML with colors and layouts, and JavaScript will bring it to life with interactivity, HTML provides the essential structure that makes everything else possible.
In this lesson, you'll create the HTML structure for a virtual terrarium interface. This hands-on project will teach you fundamental HTML concepts while building something visually engaging. You'll learn how to organize content using semantic elements, work with images, and create the foundation for an interactive web application.
By the end of this lesson, you'll have a working HTML page displaying plant images in organized columns, ready for styling in the next lesson. Don't worry if it looks basic at first – that's exactly what HTML should do before CSS adds the visual polish.
mindmap
root((HTML Fundamentals))
Structure
DOCTYPE Declaration
HTML Element
Head Section
Body Content
Elements
Tags & Attributes
Self-closing Tags
Nested Elements
Block vs Inline
Content
Text Elements
Images
Containers (div)
Lists
Semantics
Meaningful Tags
Accessibility
Screen Readers
SEO Benefits
Best Practices
Proper Nesting
Valid Markup
Descriptive Alt Text
Organized Structure
📺 Watch and Learn: Check out this helpful video overview
Before we dive into HTML code, let's set up a proper workspace for your terrarium project. Creating an organized file structure from the beginning is a crucial habit that will serve you well throughout your web development journey.
You'll create a dedicated folder for your terrarium project and add your first HTML file. Here are two approaches you can use:
Option 1: Using Visual Studio Code
Ctrl+K, Ctrl+O (Windows/Linux) or Cmd+K, Cmd+O (Mac)terrarium and select itindex.htmlOption 2: Using Terminal Commands
mkdir terrarium
cd terrarium
touch index.html
code index.html
Here's what these commands accomplish:
terrarium for your projectindex.html file💡 Pro Tip: The filename
index.htmlis special in web development. When someone visits a website, browsers automatically look forindex.htmlas the default page to display. This means a URL likehttps://mysite.com/projects/will automatically serve theindex.htmlfile from theprojectsfolder without needing to specify the filename in the URL.
Every HTML document follows a specific structure that browsers need to understand and display correctly. Think of this structure like a formal letter – it has required elements in a particular order that help the recipient (in this case, the browser) process the content properly.
flowchart TD
A["<!DOCTYPE html>"] --> B["<html>"]
B --> C["<head>"]
C --> D["<title>"]
C --> E["<meta charset>"]
C --> F["<meta viewport>"]
B --> G["<body>"]
G --> H["<h1> Heading"]
G --> I["<div> Containers"]
G --> J[" Images"]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#fff3e0
style G fill:#e8f5e8
Let's start by adding the essential foundation that every HTML document needs.
The first two lines of any HTML file serve as the document's "introduction" to the browser:
<!DOCTYPE html>
<html></html>
Understanding what this code does:
<!DOCTYPE html><html> element that will contain all page content💡 VS Code Tip: Hover over any HTML tag in VS Code to see helpful information from MDN Web Docs, including usage examples and browser compatibility details.
📚 Learn More: The DOCTYPE declaration prevents browsers from entering "quirks mode," which was used to support very old websites. Modern web development uses the simple
<!DOCTYPE html>declaration to ensure standards-compliant rendering.
Pause and Reflect: Before continuing, make sure you understand:
<html> root element containsQuick Self-Test: Can you explain in your own words what "standards-compliant rendering" means?
The <head> section of an HTML document contains crucial information that browsers and search engines need, but that visitors don't see directly on the page. Think of it as the "behind-the-scenes" information that helps your webpage work properly and appear correctly across different devices and platforms.
This metadata tells browsers how to display your page, what character encoding to use, and how to handle different screen sizes – all essential for creating professional, accessible web pages.
Insert this <head> section between your opening and closing <html> tags:
<head>
<title>Welcome to my Virtual Terrarium</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
Breaking down what each element accomplishes:
🤔 Think About This: What would happen if you set a viewport meta tag like this:
<meta name="viewport" content="width=600">? This would force the page to always be 600 pixels wide, breaking responsive design! Learn more about proper viewport configuration.
The <body> element contains all the visible content of your webpage – everything users will see and interact with. While the <head> section provided instructions to the browser, the <body> section contains the actual content: text, images, buttons, and other elements that create your user interface.
Let's add the body structure and understand how HTML tags work together to create meaningful content.
HTML uses paired tags to define elements. Most tags have an opening tag like <p> and a closing tag like </p>, with content in between: <p>Hello, world!</p>. This creates a paragraph element containing the text "Hello, world!".
Update your HTML file to include the <body> element:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to my Virtual Terrarium</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body></body>
</html>
Here's what this complete structure provides:
Now you're ready to add the visible elements of your terrarium. We'll use <div> elements as containers to organize different sections of content, and `` elements to display the plant images.
Images are special in HTML because they use "self-closing" tags. Unlike elements like <p></p> that wrap around content, the `` tag contains all the information it needs within the tag itself using attributes like src for the image file path and alt for accessibility.
Before adding images to your HTML, you'll need to organize your project files properly by creating an images folder and adding the plant graphics.
First, set up your images:
images inside your terrarium project folderimages folderNow add the plant images organized in two columns between your <body></body> tags:
<div id="page">
<div id="left-container" class="container">
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
</div>
<div id="right-container" class="container">
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
<div class="plant-holder">
</div>
</div>
</div>
Step by step, here's what's happening in this code:
id="page" to hold all contentleft-container and right-containerplant-holder div for individual positioning🤔 Consider This: Notice that all images currently have the same alt text "plant". This isn't ideal for accessibility. Screen reader users would hear "plant" repeated 14 times without knowing which specific plant each image shows. Can you think of better, more descriptive alt text for each image?
📝 HTML Element Types:
<div>elements are "block-level" and take up full width, while<span>elements are "inline" and only take up necessary width. What do you think would happen if you changed all these<div>tags to<span>tags?
Structure Understanding: Take a moment to review your HTML structure:
plant-holder divs?Visual Inspection: Open your HTML file in a browser. You should see:
Remember: This plain appearance is exactly what HTML should look like before CSS styling!
With this markup added, the plants will appear on screen, though they won't look polished yet – that's what CSS is for in the next lesson! For now, you have a solid HTML foundation that properly organizes your content and follows accessibility best practices.
Semantic HTML means choosing HTML elements based on their meaning and purpose, not just their appearance. When you use semantic markup, you're communicating the structure and meaning of your content to browsers, search engines, and assistive technologies like screen readers.
flowchart TD
A[Need to add content?] --> B{What type?}
B -->|Main heading| C["<h1>"]
B -->|Subheading| D["<h2>, <h3>, etc."]
B -->|Paragraph| E["<p>"]
B -->|List| F["<ul>, <ol>"]
B -->|Navigation| G["<nav>"]
B -->|Article| H["<article>"]
B -->|Section| I["<section>"]
B -->|Generic container| J["<div>"]
C --> K[Screen readers announce as main title]
D --> L[Creates proper heading hierarchy]
E --> M[Provides proper text spacing]
F --> N[Enables list navigation shortcuts]
G --> O[Identifies navigation landmarks]
H --> P[Marks standalone content]
I --> Q[Groups related content]
J --> R[Use only when no semantic tag fits]
style C fill:#4caf50
style D fill:#4caf50
style E fill:#4caf50
style F fill:#4caf50
style G fill:#2196f3
style H fill:#2196f3
style I fill:#2196f3
style J fill:#ff9800
This approach makes your websites more accessible to users with disabilities and helps search engines better understand your content. It's a fundamental principle of modern web development that creates better experiences for everyone.
Let's add a proper heading to your terrarium page. Insert this line right after your opening <body> tag:
<h1>My Terrarium</h1>
Why semantic markup matters:
Examples of semantic vs. non-semantic choices:
| Purpose | ✅ Semantic Choice | ❌ Non-Semantic Choice |
|---|---|---|
| Main heading | <h1>Title</h1> | <div class="big-text">Title</div> |
| Navigation | <nav><ul><li></li></ul></nav> | <div class="menu"><div></div></div> |
| Button | <button>Click me</button> | <span onclick="...">Click me</span> |
| Article content | <article><p></p></article> | <div class="content"><div></div></div> |
🎥 See It in Action: Watch how screen readers interact with web pages to understand why semantic markup is crucial for accessibility. Notice how proper HTML structure helps users navigate efficiently.
Now let's add the HTML structure for the terrarium itself – the glass container where plants will eventually be placed. This section demonstrates an important concept: HTML provides structure, but without CSS styling, these elements won't be visible yet.
The terrarium markup uses descriptive class names that will make CSS styling intuitive and maintainable in the next lesson.
Insert this markup above the last </div> tag (before the closing tag of the page container):
<div id="terrarium">
<div class="jar-top"></div>
<div class="jar-walls">
<div class="jar-glossy-long"></div>
<div class="jar-glossy-short"></div>
</div>
<div class="dirt"></div>
<div class="jar-bottom"></div>
</div>
Understanding this terrarium structure:
🤔 Notice Something?: Even though you added this markup, you don't see anything new on the page! This perfectly illustrates how HTML provides structure while CSS provides appearance. These
<div>elements exist but have no visual styling yet – that's coming in the next lesson!
flowchart TD
A[HTML Document] --> B[Document Head]
A --> C[Document Body]
B --> D[Title Element]
B --> E[Meta Charset]
B --> F[Meta Viewport]
C --> G[Main Heading]
C --> H[Page Container]
H --> I[Left Container with 7 plants]
H --> J[Right Container with 7 plants]
H --> K[Terrarium Structure]
style A fill:#e1f5fe
style B fill:#fff3e0
style C fill:#e8f5e8
style H fill:#f3e5f5
HTML Structure Mastery: Before moving forward, ensure you can:
Testing Your Understanding: Try opening your HTML file in a browser with JavaScript disabled and CSS removed. This shows you the pure semantic structure you've created!
Use the Agent mode to complete the following challenge:
Description: Create a semantic HTML structure for a plant care guide section that could be added to the terrarium project.
Prompt: Create a semantic HTML section that includes a main heading "Plant Care Guide", three subsections with headings "Watering", "Light Requirements", and "Soil Care", each containing a paragraph of plant care information. Use proper semantic HTML tags like <section>, <h2>, <h3>, and <p> to structure the content appropriately.
Learn more about agent mode here.
Learning About Web Evolution
HTML has evolved significantly since Tim Berners-Lee created the first web browser at CERN in 1990. Some older tags like <marquee> are now deprecated because they don't work well with modern accessibility standards and responsive design principles.
Try This Experiment:
<h1> title in a <marquee> tag: <marquee><h1>My Terrarium</h1></marquee><marquee> tag and return to semantic markupReflection Questions:
Explore more about obsolete and deprecated HTML elements to understand how web standards evolve to improve user experience.
Deepen Your HTML Knowledge
HTML has been the foundation of the web for over 30 years, evolving from a simple document markup language to a sophisticated platform for building interactive applications. Understanding this evolution helps you appreciate modern web standards and make better development decisions.
Recommended Learning Paths:
HTML History and Evolution
Semantic HTML Deep Dive
<article>, <section>, <aside>, and <main>Modern Web Development
Reflection Questions:
<h1>, <p>, and ``<!-- comment -->timeline
title HTML Learning Progression
section Foundation (5 minutes)
Document Structure: DOCTYPE declaration
: HTML root element
: Head vs Body understanding
section Metadata (10 minutes)
Essential Meta Tags: Character encoding
: Viewport configuration
: Browser compatibility
section Content Creation (15 minutes)
Image Integration: Proper file paths
: Alt text importance
: Self-closing tags
section Layout Organization (20 minutes)
Container Strategy: Div elements for structure
: Class and ID naming
: Nested element hierarchy
section Semantic Mastery (30 minutes)
Meaningful Markup: Heading hierarchy
: Screen reader navigation
: Accessibility best practices
section Advanced Concepts (1 hour)
HTML5 Features: Modern semantic elements
: ARIA attributes
: Performance considerations
section Professional Skills (1 week)
Code Organization: File structure patterns
: Maintainable markup
: Team collaboration
section Expert Level (1 month)
Modern Web Standards: Progressive enhancement
: Cross-browser compatibility
: HTML specification updates
After completing this lesson, you now have:
Next Steps: Your HTML structure is ready for CSS styling! The semantic foundation you've built will make the next lesson much easier to understand.