An HTML element consist of by a start tag, some content, and an end tag.


<tagname>Content goes here…</tagname>

The HTML element is everything from the start tag to the end tag:

<h1>My First Heading</h1>

<p>My first paragraph.</p>

Opening TagElement ContentClosing Tag
<p>Hello John</p>
<h1>Thanks Mediumpedia</h1>

Some HTML elements have no content (like the <br> element). These elements are called empty elements. Empty elements do not have an end tag!

Nested HTML Elements means the element contains another element.

For example:

<!DOCTYPE html>

<h1>My First Heading</h1>
<p>My first paragraph.</p>


Example Explained

The <html> element is the root element and it defines the whole HTML document. 
It has a start tag <html> and an end tag </html>. 
Then, inside the <html> element there is a <body> element.
The <body> element defines the document's body. 
It has a start tag <body> and an end tag </body>. 
Then, inside the <body> element there is two other elements
<h1> and <p> The <h1> element defines a heading. It has a start tag <h1> and an end tag </h1>.
The <p> element defines a paragraph. It has a start tag <p> and an end tag </p>


Please enter your comment!
Please enter your name here