Imagine writing out a story and then going back with a highlighter: this bit is the title, this bit is a paragraph, this bit is a picture. That is all HTML is. You write the words, then you label each piece so the browser knows what it is looking at.
The labels are called tags, and they come in pairs that wrap around the thing they describe:
<h1>Dragons</h1>
<p>Dragons are large and usually on fire.</p>â and here is what the browser makes of it
You did not tell the browser to make the title big and bold. You told it this is a heading, and it already knew what headings look like.
ð The parts of a tag
Every element has the same three parts:
<p>the opening tag â "a paragraph starts here"
Hello!the content â whatever goes inside
</p>the closing tag â note the slash
Put together, one element:
<p>Hello!</p>
ð The slash is the whole difference
<p> opens. </p> closes. Forget the slash and the browser keeps waiting for the paragraph to end â and everything after it joins in.
ð Headings come in six sizes
h1 is the biggest and most important, down to h6. Use h1 for the name of the page, and the smaller ones for sections inside it.
<h1>h1 â the title of the page</h1>
<h2>h2 â a big section</h2>
<h3>h3 â a smaller one</h3>
<p>And a p for ordinary writing.</p>Try it â this is live
â ïļ Size is not the point
It is tempting to pick h3 because you like the size. Pick by importance instead â a page with its headings in order is one a blind reader's screen reader can navigate, and one Google can understand.
ðĶī The skeleton
So far you have written the interesting bit. A complete page wraps it in a little skeleton that every web page in the world shares:
This is where it sticks. Try every one â and if you get stuck, read your own earlier answers before you peek.
ð
Task 4: Three Sections
Easy
Write an h1 called My Week, then three h2 headings â Monday, Tuesday, Wednesday â each with a paragraph after it saying anything you like.
<h1>My Week</h1>
<h2>Monday</h2>
<p>Swimming.</p>
<h2>Tuesday</h2>
<p>Piano.</p>
<h2>Wednesday</h2>
<p>Nothing at all.</p>
ð§
Task 5: Fix the Broken Tag
Medium
Type this out, but fix the mistake first â one closing tag has no slash, so the browser never learns the paragraph ended: <h1>Broken</h1> <p>This paragraph never ends.<p>
<h1>Broken</h1>
<p>This paragraph never ends.</p>
ðŽ
Task 6: Leave a Note
Easy
Write an h1 saying Secret Plans and a paragraph saying Step one: learn HTML. â and put an HTML comment between them that nobody will see on the page.
<h1>Secret Plans</h1>
<!-- step two is a secret -->
<p>Step one: learn HTML.</p>
ðŠ
Task 7: Boss Level â Nesting
Hard
Write a complete page (doctype and all). Its title should be Nesting Practice. In the body put an h1 saying Inside Out, and a paragraph containing the words this bit is bold wrapped in <strong> tags â inside the paragraph, not around it.
<!DOCTYPE html>
<html>
<head>
<title>Nesting Practice</title>
</head>
<body>
<h1>Inside Out</h1>
<p>Look, <strong>this bit is bold</strong> and this bit is not.</p>
</body>
</html>