An HTML element is a piece of content in an HTML document. It is everything from the opening tag to the closing tag.
HTML elements typically use the following syntax:
<opening tag> content </closing tag>
<p>is the opening tag.
Hello World!is the content.
</p>is the closing tag.
Note: Some HTML elements have no content, like the
<br> element. These elements are called empty elements. Empty elements do not have a closing tag, so they are referred to as self-closing. Also, self-closing tags such as
<br> can have a slash at the end like so:
Nested HTML Elements
HTML elements can be nested, which means that elements can contain other elements inside them, or nested. All HTML documents consist of nested HTML elements.
The following example contains four HTML elements:
<!DOCTYPE ><html><body><h1>Blog Post</h1><p>My first paragraph.</p></body></html>
HTML is organized into a family tree structure. HTML elements can have parents, grandparents, siblings, children, grandchildren, etc.
<body><div><h1>Heading 1</h1><h2>Heading 2</h2></div></body>
Here are the relationships depicted above in relation to the
<h1>is the child of
<div>is the parent of the
<h1>is the grandchild of
<body>is the grandparent of the
<h1>is the sibling of