HTML Elements

HTML consists of a wide range of elements, where each HTML element has an opening tag and closing tag. The content of an element is described between these tags.

Syntax of HTML Element

<elementname> Content will be added here</elementname>

Ending tag is defined with a forward slash followed by the element name.

Example:

<p> - This element will end with </p>

<h1> - This element will end with </h1>

<title> - This element will end with </title>

<br > - This element has no end tag

Some HTML Elements has no content, so do not have that closing tag. Such types of HTML elements are called empty elements, such as <br > element which indicates a line break.

Elements within other Elements

HTML Elements can be defined within the other elements.

Each HTML document consists of elements that contain elements.

Example:

<!DOCTYPE html>
<html>
<head>
<title>It shows the Title of the Page </title>
</head>
<body>

<h1>It displays the heading</h1>
<p>It displays a paragraph</p>

</body>
</html>

Here, <html> element contains the whole document.

It has an open tag <html> and close tag </html>

It has other HTML elements like <head> <title> <body> <h1> <p>

Here, <head> element is used to define the header section of an HTML document.

It has an open tag <head> and close tag </head>

<head> element has <title> element, which specifies the title of an HTML document.

Here, <body> element is used to define the document body.

It has an open tag <body> and close tag </body>

<body> element has two other HTML elements, <h1> and <p> elements.

Where, <h1> defines a heading and <p> defines a paragraph. They both have an opening and closing tag like other elements.

Keep in mind to End each element

If ever you forget or skip any HTML element to close, it may produce unexpected results and may hinder the overall view of your webpage.

So, always keep in mind to close each HTML element.

Recommended to use lowercase

As HTML tags are not case-sensitive, still we recommend you to use the lowercase in HTML.

Such as, the meaning of <P> and <H1> will remain the same as <p> and <h1>

It is better to use lowercase to make your HTML document easy to read and understand.