Learn HTML and CSS: Elements and tags
What HTML is
Maggie puts two scoops of vanilla on the counter. "One for you, one for me. Now then: what is this HTML my nephew keeps going on about?"
Tags and elements
HTML is the language you use to tell a browser what each bit of text is: a heading, a paragraph, a list.
You do that with tags: a word between angle brackets. <h1> is the opening tag of a big heading, </h1> the closing tag. The slash / makes the difference.
The opening tag, the content and the closing tag together are an element. <h1>Cold Comfort</h1> is one element: a heading with the text Cold Comfort. In the same way, <p> makes a paragraph.
You don't see the tags on the page: they only say what the text is. And <main>? That's an element too, a box around the main content. More on that in lesson 3.
<main> <h1>Cold Comfort</h1> <p>The best ice cream on the seafront.</p></main>The skeleton of a page
A complete HTML page always has the same skeleton.
<!DOCTYPE html> at the top says: this is modern HTML. Then comes <html lang="en">, with the language of the page, so a screen reader picks the right pronunciation.
<head> holds information about the page, such as the <title>: the name in the browser tab and in Google's search results. What visitors see on the page goes in <body>.
See how neatly it all fits together: <head> and <body> both open and close inside <html>.
<!DOCTYPE html><html lang="en"> <head> <title>Cold Comfort ice cream parlour</title> </head> <body> <main> <h1>Cold Comfort</h1> <p>The best ice cream on the seafront.</p> </main> </body></html>Try it yourself
Your turn. In <main>, add an <h1> heading with Welcome to Cold Comfort and below it a paragraph with Taste the sea in every scoop.
<!DOCTYPE html><html lang="en"> <head> <title>Cold Comfort ice cream parlour</title> </head> <body> <main> </main> </body></html>body { margin: 0; font-family: system-ui, sans-serif; background: #fff8f0; color: #3b2a1a;}header { padding: 24px 16px; background: #ffd6e0;}.logo { display: inline-block; margin: 8px 0 0; padding: 6px 18px; border-radius: 999px; background: #ffffff; font-size: 28px;}.slogan { margin: 8px 0 0;}main { padding: 8px 16px 24px;}Ready for more?
The full lesson has 6 exercises, from easy to challenging, with hints, points and a streak you can build.
Start the lesson