HTML elements are the main component of HTML file, which consists of the opening tag
When a tag is opened, content is introduced and the tag is closed, we have an element.
|OPENING TAG||ELEMENT CONTENT||CLOSING TAG|
|<p>||Write your paragraph here.||</p>|
|<h2>||Write your heading here.||</h2>|
HTML elements having no content and closing tag are called empty elements or self closing elements.
All the elements in HTML do not require start tag and end tag, some elemets does not have content and closing tag which are known as empty elements or void elements.
They are also known as unpaired tag.
Example for empty element:
<br> : represents a line break
<ol> : used to make ordered list
Nested HTML Elements
HTML elements can be nested which means an element can contain another element.
They are made up of tags, attributes, and content or other elements.
NOTE: In nested HTML elements number of elements can be there except empty elements.
Example for Nested elements:
<!DOCTYPE html> <html> <body> <h1> My first heading </h1> <p> My first paragraph </p> </body> </html>
Elucidation of example:
The </html> element defines the whole html file.
Inside the </html> element is the </body> element.
The body element defines the main content of html file which is displayed on browser.
Every element is having opening and closing tag.
Inside the body element there are two more elements named <h1> and <p>.