Lesson 2 ยท Make a web page

Tags are labels

Write real HTML to make an "All about me" page.

About 15 minutes

Tab indents. Press Escape, then Tab, to leave the editor.

In the last lesson you met tags, the words in pointy brackets. Now you'll learn how they work and write them yourself. By the end you'll have your very own "All about me" page. ๐Ÿ™‹

Tags are labels on boxes

Imagine you're packing up your room. You put things in boxes and stick a label on each one: "BOOKS ๐Ÿ“š", "TOYS ๐Ÿงธ", "SOCKS ๐Ÿงฆ". The label doesn't change what's inside. It just tells everyone what the box holds.

Tags work the same way. They wrap around a piece of your page and tell the browser what it is:

<h1>My Awesome Page</h1>

The browser reads this and thinks: "Aha, this is the big main title!" Then it draws the words big and bold.

Opening and closing

Most tags come in pairs, like the two sides of a sandwich. ๐Ÿฅช

  • The opening tag goes at the start: <h1>
  • The closing tag goes at the end. It looks the same, but with a slash: </h1>
  • Your words go in the middle, like the filling.

The whole thing together, from the opening tag to the closing tag, is called an element. So <h1>My Awesome Page</h1> is one heading element.

Question

Quick check

Which one is the closing tag for <p>?
Pick an answer.

Some tags to know

Here are a few tags you'll use all the time. The letters are short for real words, which makes them easier to remember.

TagShort forWhat it's for
<h1>heading 1The biggest, most important title. Usually one per page.
<h2>heading 2A smaller title for each part of your page
<p>paragraphOrdinary sentences
<strong>strongWords that really matter. They show up bold.
<ul>unordered listA list with dots instead of numbers
<li>list itemOne thing in a list

There are headings all the way from <h1> down to <h6>, which gets smaller each time.

Boxes inside boxes

Some tags hold other tags inside them, like a big box with smaller boxes in it. ๐Ÿ“ฆ A list is a great example. The <ul> is the big box, and each <li> is a small box inside:

<ul>
  <li>Pizza</li>
  <li>Swimming</li>
  <li>Dragons</li>
</ul>

See how the <li> lines are pushed in a little? That's called indenting. The browser doesn't need it, but it helps people see which boxes are inside which.

When you put tags inside other tags, close the inside one first. A small box has to be closed before you can close the big box around it.

Question

Quick check

You want to add "Ice cream" to a list. Which line do you add inside the <ul>?
Pick an answer.

Make your "All about me" page

Now it's your turn to be the web page builder! ๐Ÿ› ๏ธ

Challenge

All about me

Make this page all about you:

  1. Put your name (or a nickname) in the big <h1> title.
  2. Change the paragraph to a sentence about you.
  3. Make the list show at least 3 things you like. Each one needs its own <li>.

Bonus: wrap one important word in <strong> and </strong> to make it bold.

  • Your big title has your name in it
  • Your paragraph tells us something about you
  • Your list has at least 3 things you like

What you learned

  • Tags are labels that tell the browser what each part of the page is.
  • Most tags come in pairs: an opening tag like <p> and a closing tag like </p>. Together with what's inside, they make an element.
  • <h1> and <h2> make titles, <p> makes paragraphs, <strong> makes bold words, and <ul> with <li> makes a list.
  • Tags can go inside other tags, like boxes inside boxes.
  • You built your own "All about me" page! ๐ŸŽ‰

Finished this lesson?

Mark it complete to track your progress on this device.

Next: Paint with CSS