Element
In one line
An HTML element is a piece of a web page defined by a start tag, content, and an end tag, like <p>Hello</p>.
In simple words
An HTML element is a single component of a web page — a heading, paragraph, image, link, button, and so on. Each element is created by an opening tag (e.g. <p>), optional content between the tags, and a closing tag (e.g. </p>).
Some elements have no content and no closing tag — these are called void or self-closing elements. <img>, <br>, and <input> are examples. They exist as a single tag that may carry attributes.
Elements can be nested inside each other, forming the tree structure of the DOM. A <div> might contain a <ul>, which contains several <li> elements. Each element has a type (its tag name) and may have attributes that configure its behavior.
Example
<!-- A paragraph element with content -->
<p class="intro">Hello, World!</p>
<!-- A self-closing image element -->
<img src="logo.png" alt="Logo" />
<!-- Nested elements -->
<ul>
<li>First item</li>
<li>Second item</li>
</ul>Elements are defined by tags. <p> has content, <img> is self-closing, and <ul> contains <li> children.
Related terms
Related Resources
Related Lessons
- HTML
Elements are the core of HTML
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.