HTML element

an HTML element is defined as starting tag, content and ending tag

let us see some examples of elements with different tags:

  • <h1> Hello world </h1>

  • <p> this is a paragraph </p>

some elements don't have content these elements are called empty elements. Empty elements don't have the ending tag

let us see some examples of empty elements :

  • <br>

  • <input>

Nested HTML elements:

Nested HTML elements are nothing but elements can contain other elements

let us see an example :

<!DOCTYPE html>
<html>
<body>

<h1> hello world this is heading </h1>
<p> new paragraph</p>
<footer> this is footer </footer>

</body>
</html>

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:

<body>

<h1> hello world this is heading </h1>
<p> new paragraph</p>
<footer> this is footer </footer>

</body>

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 are three other elements: <h1> ,<p> and </footer>:

<h1> hello world this is heading </h1>
<p> new paragraph</p>
<footer> this is footer </footer>

The <h1> element defines a heading.

It has a start tag <h1> and an end tag </h1>:

<h1> hello world this is heading </h1>

The <p> element defines a paragraph.

It has a start tag <p> and an end tag </p>:

<p>My first paragraph.</p>

The <footer> element defines a footer.

It has a start tag <footer> and an end tag </footer>:

<footer> this is footer </footer>