Skip to content

Elements vs Tags

People often use “tag” and “element” to mean the same thing. They are related but not identical.

A tag is the syntax you type — the angle brackets and the name inside them.

<p> ← opening tag
</p> ← closing tag

Tags come in two forms:

  • Opening tag — marks where the element starts: <p>
  • Closing tag — marks where it ends, with a forward slash: </p>

An element is the complete unit: opening tag + content + closing tag.

<p>This is a paragraph.</p>
PartWhat it is
<p>Opening tag
This is a paragraph.Content
</p>Closing tag
All three togetherThe element

Some elements have no content and therefore no closing tag. These are called void elements.

<img src="photo.jpg" alt="A mountain landscape">
<br>
<hr>

There is nothing to wrap, so there is nothing to close.

MisconceptionReality
<p> is a paragraph<p> is an opening tag. <p>Some text</p> is a paragraph element.
Tags and elements are the same thingTags are syntax; elements are structural units.
Every element needs a closing tagVoid elements like <img> and <br> do not.

Open index.html from the previous lesson in VS Code.

Find these three lines in the file and answer the questions for each:

  1. <title>My First Page</title>
  2. <h1>Hello, world!</h1> (or whatever you changed it to)
  3. <meta charset="utf-8">

For each one, write down:

  • Is it a normal element or a void element?
  • What is the opening tag?
  • What is the content (if any)?
  • What is the closing tag (if any)?

One of the three is a void element — which one, and how can you tell?

  • A tag is the syntax inside < >.
  • An element is the full unit: opening tag + content + closing tag.
  • Void elements (<img>, <br>, <hr>) have no content and no closing tag.