On this page10 sections
  1. Learning Objectives
  2. 1. The Parts of an Element
  3. 2. Nesting: Elements Inside Elements
  4. 3. Empty Elements
  5. 4. Tags Are Not Case-Sensitive, But…
  6. Code Examples
  7. Common Beginner Mistakes
  8. Practice Questions
  9. Practice Answers
  10. Key Takeaways

Lecture 003: Elements & Tags

Category1: Getting Started
Lecture003 of 048
Estimated video length10 min
TargetHTML5 · any modern browser
LevelBeginner

An element is one piece of a page: a heading, a paragraph, an image. You write an element with tags. Once you can tell tags, content and elements apart, every other HTML topic is just learning new tag names.


Learning Objectives

  • Name the three parts of an element: opening tag, content, closing tag
  • Nest elements correctly inside each other
  • Recognise empty (self-closing) elements such as <br> and <img>

1. The Parts of an Element

output
<p>Hello there</p>
│ │          │
│ │          └── closing tag (has a slash)
│ └──────────── content
└────────────── opening tag

The opening tag, the content and the closing tag together make one element.

Example

html
<h2>Today's menu</h2>
<p>Chicken karahi with fresh naan.</p>

2. Nesting: Elements Inside Elements

An element can hold other elements. The inner one must close before the outer one.

Example

html
<p>Delivery is <strong>free</strong> today.</p>

<strong> opens and closes inside the <p>. Think of boxes: a small box must fit completely inside a bigger box.

output
Right:  <p> ... <strong> ... </strong> ... </p>
Wrong:  <p> ... <strong> ... </p> ... </strong>

3. Empty Elements

Some elements have no content, so they have no closing tag.

ElementWhat it does
<br>Line break inside text
<hr>A horizontal dividing line
<img>An image (Lecture 011)

Example

html
<p>House 12, Street 4<br>Lahore<br>Pakistan</p>
<hr>
<p>Open every day, 9am to 9pm.</p>

4. Tags Are Not Case-Sensitive, But…

<P> and <p> both work, but always write lowercase. It's the standard, and every code example you'll find online uses it.


Code Examples

Example 1: A Recipe Card

html
<h2>Mint Lemonade</h2>
<p>Ready in <strong>5 minutes</strong>.</p>
<hr>
<p>Blend lemon juice, mint, sugar and ice.<br>Serve cold.</p>

Common Beginner Mistakes

1. Forgetting the closing tag. Without </strong>, everything after it turns bold.

2. Overlapping tags. <p><strong>Hi</p></strong> closes in the wrong order. Close the inner tag first.

3. Using <br> for spacing. Several <br>s in a row to push content down is a hack. Use separate paragraphs, and later CSS margins.

4. Writing </br>. <br> has no closing tag.


Practice Questions

  1. What are the three parts of <h1>Welcome</h1>?
  2. Is <em>Hi <strong>there</em></strong> nested correctly? Why?
  3. Name two empty elements.
  4. Write HTML that shows "Line one" and "Line two" on separate lines inside one paragraph.
  5. Should you write tags in upper or lower case?

Practice Answers

  1. Opening tag <h1>, content Welcome, closing tag </h1>.
  2. No. <strong> opened inside <em>, so it must close before </em>: <em>Hi <strong>there</strong></em>.
  3. Any two of <br>, <hr>, <img>.
  4. <p>Line one<br>Line two</p>
  5. Lowercase.

Key Takeaways

  • Element = opening tag + content + closing tag.
  • Close inner elements before outer ones, like boxes inside boxes.
  • Empty elements (<br>, <hr>, <img>) have no closing tag.
  • Write tags in lowercase.