Elements & Tags

HTML content is built from elements. Each element is usually made of an opening tag, some content, and a closing tag.

Anatomy of an element

</> anatomy
<p>This is a paragraph.</p>
↑           ↑              ↑
opening tag   content        closing tag

The closing tag looks like the opening tag but with a forward slash before the tag name — </p>, not <p/>.

Nesting elements

Elements can contain other elements. When they do, closing tags should close in the reverse order the opening tags appeared — like closing brackets that match. Try adding another <strong> or <em> below:

Try it yourself
Result

Void elements

Some elements don't wrap any content, so they don't need a closing tag at all. These are called void elements. A line break is one example:

Try it yourself
Result
Common void elements: <br>, <img>, and <hr> are three you'll use often — none of them wrap content, so none of them need a closing tag.