HTML is built from elements. An element is usually an opening tag, some content, and a closing tag — the tags tell the browser what kind of content it is.
Anatomy of an element
<p>This is a paragraph.</p>│ content │└ opening tag └ closing tag (note the /)<img src="cat.jpg" alt="A cat" /> <!-- void element: no closing tag -->
Nesting
Elements nest inside one another, forming a tree. Nested elements must be closed in the reverse order they were opened:
<p>This is <strong>bold and <em>italic</em></strong> text.</p><!-- WRONG — tags overlap instead of nesting --><p><strong>bad <em>overlap</strong></em></p>
Key takeaways
- 01An element = opening tag + content + closing tag (e.g. <p>...</p>).
- 02Void elements (<img>, <br>, <input>) have no content or closing tag.
- 03Elements nest to form a tree; close inner elements before outer ones.
- 04Overlapping tags are invalid — proper nesting is required.
