What is HTML Elements

Last updated 3 weeks, 5 days ago | 79 views 75     5

Tags:- HTML

HTML  | What is HTML Elements

HTML elements help to create a webpage. It consists of a start tag, some content, and an end tag.

 

Everything from the start tag to the end tag is an HTML element:

<tagname>Some Contents...</tagname>

Examples:

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

Note: Some HTML elements do not have an ending tag (eg.<br> element) hence it does not contain any content It is called empty elements.


Nested HTML Elements

HTML element can also contains other HTML elements

<html>

   <head>
      <title>Nested HTML Elements Example</title>
   </head>
	
   <body>
      <h1>This is heading</h1>
      <p>This is paragraph</p>
   </body>
	
</html>

Example Explained

<html>...</html> The <html> is the root element for a HTML document. It defines the whole HTML document.
<head>...</head> This tag contains all the metadata for the page, stuff mostly meant for search engines and other computer programs.
<title>...</title> This is used to specify the page name and it appears at the top of the browser window or tab.
<body>...</body> The <body> element defines the visible part of the HTML document.
<h1>...</h1> This is use for heading
<p>...</p> This tag is used to defines paragraph in the HTML document

Empty HTML Elements

HTML elements with no content and without a closing tag are called empty elements. The <br> tag defines a line break, and is an empty element without a closing tag:

<p>A paragraph with <br> line break.</p>