Thuta Learning
HTML
BasicWeb DevelopmentBeginner

HTML Intro

HTMLLesson 215 min

What you'll walk away with

  • Explain what each word in HyperText Markup Language means
  • Explain why the browser runs untagged text together into one line
  • Use <h1> and <p> to label plain text as a heading and paragraphs
  • Choose elements for their meaning rather than their default look

Explain it simply

Explain it simply

Imagine marking up a printed page with a pen. Next to the title you write "title", next to each block of text "paragraph", next to the shop's address "link". HTML does exactly that job: it does not change the content, it attaches labels the browser understands to each piece.

Those labels are called tags. <h1> says "the main heading starts here" and </h1> says "it ends here". The browser reads the labels and shows the heading large and each paragraph as its own block.

Problem → Why → Solution

The problem: your line breaks disappear

Say you type a shop announcement neatly in your editor, with a title line, sentences and a blank line between them, and save it as sale.html. When you open it in the browser, everything becomes one long line: "Rainy Season Sale Everything in the shop is 20% off this week. Visit us at 45 Bogyoke Road." The title is not bigger, and the paragraphs are gone.

sale.html
Rainy Season Sale
Everything in the shop is 20% off this week.

Visit us at 45 Bogyoke Road.

Why does this happen?

To the browser, Enter keys and runs of spaces in the source carry no meaning: in normal text, any run of whitespace is collapsed into a single space. Structure can only come from tags. Once you add <h1> and <p>, the browser knows which part is the title and which parts are paragraphs.

Core concept: HTML describes content

Each word in the name tells you something about what HTML does:

WordWhat it means
HyperTexttext that links to other documents
Markuplabelling parts of the text with tags
Languagea set of rules for how tags are written

HTML is not a programming language. It has no variables, loops or if conditions, and it does not calculate: write <p>2 + 3</p> and the browser shows "2 + 3", not 5. HTML describes what things are, while JavaScript handles what should happen. That is why HTML is called a markup language.

Every browser has a default stylesheet, which is why <h1> appears big and bold and each <p> gets space above and below it. But the look is not the point. <h1> means "the main heading of the page", and screen readers, search engines and the browser's reader mode all use that meaning. You can change the look freely with CSS later; the meaning only comes from the tag you choose.

A start tag, its content and its end tag together make an element. Elements can sit inside other elements, the way a paragraph can contain a link, and the browser keeps track of which element is inside which. Tag names are not case-sensitive, so <P> and <p> work the same, but the convention everywhere is lowercase, and every example in this course follows it. Lesson 5 covers elements properly; for now it is enough to recognise the start tag, the content and the end tag.

HTML is defined by the "HTML Living Standard", maintained by the WHATWG. People often say "HTML5", but there is no longer a series of numbered versions; the standard is updated continuously. HTML is also forgiving: even if you forget to close a tag, the browser still tries to show the page. The next lesson looks at how it does that.

Mental model: labels on plain text
  1. Plain text has no structure
  2. Tags label each piece
  3. Browser applies default styles
  4. Tools rely on the label meanings

Pick a tag for what the content is, never for how the tag happens to look.

General pattern

html
<tag>content that the tag describes</tag>

<h1>The main heading of the page</h1>
<p>A paragraph of ordinary text.</p>

The content you want to label goes between a start tag and an end tag (the one with /). h1 is the page's main heading, p is one paragraph.

Example: one heading and one paragraph

Two kinds of tag are enough to give the browser structure. Put these lines inside the <body> of your index.html, or even into an empty file on their own; the browser will still show them.

html
<h1>Hello World!</h1>
<p>This is my first paragraph.</p>

Code breakdown

  1. Line 1<h1>Hello World!</h1>

    <h1> opens the main heading and </h1> closes it. Only "Hello World!" between them appears on screen; the tags themselves are never shown.

  2. End tag</h1>

    The end tag has a /. Without it the browser cannot tell where the heading stops, which causes trouble you will see in the next lesson.

  3. Line 2<p>This is my first paragraph.</p>

    <p> marks a paragraph. Even if you wrote it on the same source line as the h1, the browser would still start it on a new line: structure comes from the tag, not from Enter.

You should see
A large bold heading "Hello World!" appears at the top, and below it, after some space, the normal-sized paragraph "This is my first paragraph."

Peek at the HTML of real websites

Open any website you like and press Ctrl+U (Cmd+Option+U on a Mac) to see the HTML source the server sent. Right-click a piece of text and choose "Inspect", and DevTools highlights that element. There will be a lot of code at first, but look for tags like <h1> and <p>: big sites use exactly what you learned in this lesson.

View Source and Inspect are not the same

View Source shows the file exactly as the server sent it. The Elements panel in DevTools shows the page as the browser understood it, after any repairs and after any JavaScript changes. When the two disagree, the difference is often a clue to a bug, as the next lesson explains.

In real projects

Why this matters in real projects

Programs read your labels more than people do. Many screen reader users move through a page by jumping between headings (the H key in NVDA and JAWS); if your headings are plain <div> elements, that route simply does not exist. Search engines also use the heading and paragraph structure to understand what a page is mainly about.

The browser's reader mode, page translation features and the link previews shown when you share a URL in a chat app all depend on the markup too. In teams, when a designer hands over a mockup, a developer's first job is to break the picture into "this is a heading, this is a paragraph, this is a list", and only then write the CSS.

Common mistakes

Common mistakes

1. Using <h1> just to get big text

Putting "Free delivery!" in an <h1> because you want it to stand out tells screen readers and search engines that it is the page's main title. If it is not a heading, use <p> and change the look with CSS.

2. Relying on Enter and spaces for layout

Typing ten spaces to indent text, or three blank lines to push it down, does nothing because the browser collapses it all into one space. Use <p> to separate paragraphs and control spacing with CSS.

3. Expecting HTML to calculate or decide

<p>Total: 1500 + 2000</p> will never show 3500; it shows the text exactly as written. Calculations and content that changes with the user's choices need JavaScript or server-side code.

Mini challenge

Mini challenge: mark up the announcement

Fix the sale announcement from the problem section, which ran together into one line, by adding tags, and add one more sentence with the opening hours.

  • "Rainy Season Sale" must be the page's main heading
  • Each sentence must be its own paragraph
  • Add "Open 9:00 to 18:00, Monday to Saturday." as a new paragraph
  • Open it in a browser and check that four separate blocks appear
sale.html
<!-- TODO: label this line as the main heading -->
Rainy Season Sale
<!-- TODO: make each sentence its own paragraph -->
Everything in the shop is 20% off this week.
Visit us at 45 Bogyoke Road.
<!-- TODO: add a paragraph with the opening hours -->

Expected: "Rainy Season Sale" appears as a large heading, with three paragraphs below it, each on its own line.

Show hint

You do not need to retype the text; just put a start tag before and an end tag after each line. Do not forget the / in each end tag.

Show solution
sale.html
<h1>Rainy Season Sale</h1>
<p>Everything in the shop is 20% off this week.</p>
<p>Visit us at 45 Bogyoke Road.</p>
<p>Open 9:00 to 18:00, Monday to Saturday.</p>

Quick quiz 1 / 3

In the source, <p>Hello world</p> has ten spaces and an Enter between Hello and world. How does the browser show it?

Quick quiz 2 / 3

Which statement about HTML is true?

Quick quiz 3 / 3

You want "Free delivery on orders over 30,000 Ks" to stand out, but it is not the page's title. What should you do?

What to remember

  • HTML = HyperText Markup Language: it labels linked text with tags.
  • HTML is not a programming language; it describes content and never calculates.
  • The browser collapses whitespace in the source, so structure only comes from tags.
  • Choose tags for their meaning and change their look with CSS.

HTML Living Standard — WHATWG

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

HTML Intro | Thuta Learning