Chapter 2 of 15

HTML Basics: Tags, Headings, Paragraphs and Lists

HTML is made of tags. Most tags work the same way, so learning a few teaches you the pattern.

Tags and elements

A tag is a word inside angle brackets, like <p>. Most tags come in pairs: an opening tag and a closing tag. The closing tag has a slash /.

The code p This is a paragraph slash p with labels for opening tag, content and closing tag
The closing tag has a slash /. Together, the three parts are called an element.
HTML
<p>This is a paragraph.</p>

The opening tag, the content and the closing tag together are called an element.

RememberAlways close what you open. If you forget </p>, the browser has to guess, and sometimes it guesses wrong.

Tags inside tags (nesting)

Tags can go inside other tags. This is called nesting. The rule is simple: the last tag you opened is the first one you close, like boxes inside boxes.

HTML
<!-- Correct: strong is closed before p -->
<p>This is <strong>very</strong> important.</p>

<!-- Wrong: the tags cross each other -->
<p>This is <strong>very important.</p></strong>

Indent the inner tags with two spaces. It shows you at a glance which tag is inside which:

HTML
<ul>
  <li>Fruits
    <ul>
      <li>Mango</li>
      <li>Banana</li>
    </ul>
  </li>
</ul>
Result in the browser
  • Fruits
    • Mango
    • Banana

The basic page structure

Every HTML page uses the same starting structure. Copy it every time you make a new page.

Nested boxes: html contains head with title and meta, and body with h1 and p
Every page has the same shape: <html> holds a <head> and a <body>.
HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Page title for Google and the browser tab</title>
  </head>
  <body>
    <!-- Everything people see goes here -->
  </body>
</html>
  • <!DOCTYPE html> tells the browser "this is a modern HTML page".
  • <html lang="en"> wraps the whole page. lang tells Google and screen readers the language.
  • <head> holds information about the page. People do not see it on the page.
  • <body> holds everything people see.

Headings and paragraphs

There are six heading levels, <h1> to <h6>. h1 is the most important. Use only one h1 per page. It is the main title. Google reads headings to understand your page.

An outline tree: one h1, then h2 sections, each with h3 sub-sections
Headings work like the outline of a book. Google reads this outline to understand your page.
HTML
<h1>My Travel Blog</h1>
<h2>Trip to Jaipur</h2>
<p>Jaipur is called the Pink City.</p>
<h3>Where we stayed</h3>
<p>We stayed near Hawa Mahal.</p>
Result in the browser
My Travel Blog
Trip to Jaipur

Jaipur is called the Pink City.

Where we stayed

We stayed near Hawa Mahal.

Do not pick headings by sizeChoose the heading level by importance, not by how big it looks. You can change the size later with CSS.

Bold, italic and line breaks

HTML
<p>This is <strong>very important</strong> text.</p>
<p>This word has <em>emphasis</em>.</p>
<p>Line one<br>Line two</p>
<hr>
Result in the browser

This is very important text.

This word has emphasis.

Line one
Line two


<br> and <hr> have no closing tag. They are called empty elements.

Spaces and new lines are ignored

This surprises everyone at first. The browser turns many spaces and new lines into one single space.

HTML
<p>Hello



      world</p>
Result in the browser

Hello world

To control where text breaks, use tags: a new <p> for a new paragraph, or <br> for a line break inside one (useful for addresses and poems). Spacing between blocks is a job for CSS, which you will learn soon.

Special characters

Some characters have a special meaning in HTML. If you want to show them as normal text, write a short code instead. These codes are called entities.

You want to showWrite this
<&lt;
>&gt;
&&amp;
©&copy;
A space that never breaks&nbsp;
HTML
<p>Use the &lt;p&gt; tag for paragraphs. &copy; 2026 My Site</p>
Result in the browser

Use the <p> tag for paragraphs. © 2026 My Site

Lists

Use <ul> for a list with bullet points (order does not matter). Use <ol> for a numbered list (order matters). Each item goes inside <li>.

HTML
<h3>Shopping list</h3>
<ul>
  <li>Milk</li>
  <li>Bread</li>
</ul>

<h3>Make tea</h3>
<ol>
  <li>Boil water</li>
  <li>Add tea leaves</li>
  <li>Add milk and sugar</li>
</ol>
Result in the browserShopping list
  • Milk
  • Bread
Make tea
  1. Boil water
  2. Add tea leaves
  3. Add milk and sugar

One more list: the description list

For a word and its meaning, like a glossary or FAQ, use <dl>. Each term goes in <dt> and its description in <dd>.

HTML
<dl>
  <dt>HTML</dt>
  <dd>The language for page structure.</dd>
  <dt>CSS</dt>
  <dd>The language for page design.</dd>
</dl>
Result in the browser
HTML
The language for page structure.
CSS
The language for page design.

Comments

A comment is a note for you or other developers. The browser does not show it.

HTML
<!-- This is a comment. Nobody sees it on the page. -->

Check your HTML for mistakes

Browsers are kind. They try to show a page even when the HTML is broken, so mistakes can hide. A validator finds them for you.

  1. Open the free W3C validator at validator.w3.org.
  2. Choose Validate by Direct Input and paste your code.
  3. Click Check. Fix the first error first, because one mistake often causes several messages.

Mini project: an "About me" page

Let us use everything from this chapter in one page. Make a new file called about.html:

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>About Priya</title>
  </head>
  <body>
    <h1>Hi, I'm Priya</h1>
    <p>I am learning <strong>web development</strong> and I love cooking.</p>

    <h2>My skills</h2>
    <ul>
      <li>HTML (learning now)</li>
      <li>CSS (next month)</li>
    </ul>

    <h2>My goals for this year</h2>
    <ol>
      <li>Finish this course</li>
      <li>Build a recipe website</li>
      <li>Get my first freelance client</li>
    </ol>
  </body>
</html>

Change the name, skills and goals to your own. It looks plain for now. In chapter 4 you will make it look good with CSS.

Common mistakes

MistakeFix
Forgetting a closing tag, so everything after it turns bold or bigCheck that each opening tag has its closing tag
Using <br> many times to make spaceUse separate paragraphs, then add space with CSS
Putting text directly in <ul>Every item must be inside <li>
Skipping from h1 to h4 because h4 "looks right"Go in order (h1, h2, h3) and change the size with CSS

Practice time

  1. Make a page called about.html with one h1, two h2 sections and a paragraph under each.
  2. Add a numbered list of your three favourite foods.
  3. Make one word bold and one word italic.
  4. Paste your about page into the W3C validator and fix any errors.
  5. Show the text <h1> on a page so it appears as text, not as a heading.

Quick summary

  • Tags come in pairs: <p> and </p>.
  • Use the same page structure every time: doctype, html, head, body.
  • One h1 per page. Pick heading levels by importance.
  • ul = bullets, ol = numbers, li = each item.