Elements in HTML

An HTML element is defined as a whole HTML tag. This element may contain content else it will be known as an empty element.
Below are some HTML tags creating element -:

Start Tag Content End Tag End Tag

<h1> Heading of page goes here. </h1>
<p> paragraphs of page goes here. </p>
<div> Div content of your page. </div>
<br /> —> Empty element line break.
<img.../> —–> Empty element image

So above we seen some element like <p> content </p> which have start tag and end tag. Some elements don’t have their end tag. These kinds of elements are known as void or empty elements.

Don’t Miss the End Tag.

Some HTML elements will work correctly, even if you miss the end tag. But it is advised to close the non-empty elements properly.

<html>
<head>
</head>
<body>

<H1>This is a heading
<p>This is a paragraph

</body>
</html>

Above, we are not closing our h1 tag properly, so the browser also makes our paragraph <p> look like a heading.

Nested HTML Elements

The nested HTML means that some HTML elements can contain other HTML elements. Without nesting the HTML elements, it is difficult to build a proper structure.

<!DOCTYPE html>
<html>

   <head>
      <title>Example of nested elements</title>
   </head>
	
   <body>
      <h1>This is <b>bold</b> heading</h1>
      <p>This is <em>emphasized</em> paragraph</p>
   </body>
	
</html>

In the above example the root <html> element containing other child elements like <body> and <head>.

Leave a Reply

Your email address will not be published. Required fields are marked *