HTML Fundamentals

Session 4 — HTML Layout, div, span, and Semantic HTML

🎯 Session Overview

Welcome to your final session of HTML Fundamentals! You've learned how to add text, images, links, lists, and tables. But real websites don't just stack everything in one giant column. They have headers, footers, and sidebars.

Today, you will learn how to structure a professional web page. You will learn:

⏪ Quick Review: Session 3

Before we dive into layouts, let's remember what we learned about organizing data:

🏗️ Page Layout Concept

Think about your favorite website, like YouTube or a gaming wiki. Everything is divided into neat, organized sections.

Usually, a website is split into these main parts:

HEADER NAVIGATION MAIN CONTENT FOOTER

How do we build these boxes in HTML? We use a tag called div!

📦 The <div> Element

The <div> element stands for Division. It is an invisible container used to group other HTML elements together.

Imagine a <div> as an empty cardboard box. You can put headings, paragraphs, and images inside that box to keep them all together. This makes it super easy to style sections later using CSS!

<!-- This div groups the "About Me" section together -->
<div>
  <h2>About Me</h2>
  <p>My name is Alex and I love coding.</p>
</div>

<!-- This div groups the "Hobbies" section -->
<div>
  <h2>My Hobbies</h2>
  <ul>
    <li>Gaming</li>
    <li>Skateboarding</li>
  </ul>
</div>

1. We open the first <div>. Everything after this is "inside the box".

2. We add an h2 and a p element.

3. We close the box with </div>. The "About Me" section is complete.

4. We create a second, separate <div> for the Hobbies list. Now the two sections are cleanly separated!

🖌️ The <span> and Formatting Elements

A <div> is a "Block" element. It stacks like blocks on top of each other. But what if you want to highlight just one specific word inside a paragraph without breaking it onto a new line?

For this, we use Inline Elements like <span>.

A <span> is a mini-container for text. By itself, it does nothing, but it allows you to target specific words. HTML also gives us built-in inline formatting tags:

<p>My favorite color is <span style="color: blue;">blue</span>.</p>

<p>Warning: Do <b>NOT</b> press the <mark>red button</mark>!</p>

Block vs Inline

<div> takes the whole width (Block) Here is a sentence with <span>inline</span> text inside.

🧠 Semantic HTML Elements

Using <div> for everything works, but it makes the code hard to read. Imagine opening a document and seeing 50 <div> tags. You wouldn't know which one is the header and which is the footer!

Semantic HTML solves this. "Semantic" means "having meaning." Instead of using blank <div> boxes, we use tags that describe exactly what is inside them.

<header>: Replaces the top div.
<nav>: Holds your navigation links.
<main>: Holds the primary content.
<footer>: Replaces the bottom div.
<body>
  <header>
    <h1>Welcome to My Website</h1>
  </header>

  <main>
    <section>
      <h2>About Me</h2>
      <p>I am a programmer!</p>
    </section>
  </main>

  <footer>
    <p>© 2026 TechTicket</p>
  </footer>
</body>

Using semantic tags makes your code cleaner, helps search engines (like Google) understand your site, and makes it accessible for screen readers!

🏋️ Practice Exercises

Open your code editor. Let's put your new layout skills to the test!

Exercise 1: Top and Bottom

Create a blank HTML page. Use semantic tags to create a <header> with an `h1` title, and a <footer> with a simple copyright paragraph. Leave the middle blank for now.

Put the <header> directly below the opening <body> tag, and the <footer> right above the closing </body> tag.

Exercise 2: Building Sections

In the middle of your page (between header and footer), use two <div> containers. Make the first div an "About Me" section, and the second div a "My Hobbies" section.

<div> <h2>About Me</h2> <p>...</p> </div>

Exercise 3: Make it Pop!

Inside your "About Me" paragraph, use the <b> tag to make your name bold, and use the <mark> tag to highlight your favorite word.

<p>My name is <b>Alex</b> and I <mark>love</mark> gaming.</p>

🚀 Final Mini Project: Personal Website

This is it! Time to use everything you've learned in the course to build a complete, properly structured personal website.

Your page must include all of the following in this order:

  1. A <header> with your name in an <h1>.
  2. A <main> container that holds everything else.
  3. An "About Me" <section> with a paragraph.
  4. A "My Favorites" <section> containing an Unordered List (<ul>) of your favorite things.
  5. An <img> of something you like (a game, animal, sport).
  6. A <footer> with a copyright symbol (&copy;) and the current year.
<body>
  <header>
    <h1>Welcome to Sarah's World</h1>
  </header>

  <main>
    <section>
      <h2>About Me</h2>
      <p>I am learning <b>HTML</b> at TechTicket!</p>
    </section>
    
    <section>
      <h2>My Favorites</h2>
      <ul>
        <li>Coding</li>
        <li>Pizza</li>
      </ul>
      <img src="pizza.jpg" width="300">
    </section>
  </main>

  <footer>
    <p>&copy; 2026 Sarah. All rights reserved.</p>
  </footer>
</body>

🏠 Homework: The Final Polish

Take your Mini Project website and turn it into a masterpiece to show your friends and family!

Improve your website by adding:

📚 Course Summary: You did it!

Let's review the final concepts you've mastered today:

Congratulations on completing HTML Fundamentals!

⬅ Previous Session Finish Course 🏆