Opening, Closing, and Self-Closing Tags
A free lesson from Swipe Coding · HTML, level 1 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Most HTML tags come in pairs: an opening tag like <p> and a matching closing tag like </p>, with content sandwiched between them. The closing tag is identical to the opening one except for the forward slash right after the <.
<p>This is a paragraph.</p>
Some tags never wrap content at all, so they have no separate closing tag — they're called self-closing (or void) elements. <img>, <br>, and <input> are common examples: an image tag doesn't wrap text, a line break doesn't wrap anything, so neither needs </img> or </br>.
<img src="photo.jpg" alt="A photo"> <br>
Forgetting a closing tag on a paired element is one of the most common beginner mistakes, and it's often the cause of a page looking subtly broken — content nested in the wrong place, or formatting bleeding further than intended. Getting into the habit of closing every paired tag prevents most of these bugs before they happen.
Which of these is a self-closing (void) element that never needs a closing tag?
A closing tag is written the same as an opening tag, but with a forward ____ right after the <.
Every single HTML tag requires a matching closing tag.
Keep your streak going in Swipe Coding
Swipe through every level of HTML on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →