HTML Elements | Types, Example

An HTML document is a text file that consists of elements. These elements are the basic foundation of creating any web page. They are used to defining the basic structure and content in the web page.

A pair of tags and the content within (or between) those tags are known as an HTML element.

Technically, an element in HTML usually consists of start tag <tag name>, attributes, close tag </tag name> and content between them.

Each HTML element has a specific role that we generally use to add headings, paragraphs, links, tables, images, forms, tables, and other elements to a web page.

We define an HTML element by opening and closing tags. The syntax of an HTML element is as follows:


Look at the below figure where we have shown HTML element syntax more nicely.

Syntax of HTML elements

As shown in the above figure, an element is identified by tags and the content inserted between those tags. A tag consists of the element name (or tag name) within angle brackets (< >).
[adinserter block=”5″]
The opening tag, also called start tag (<elementname>) says the browser, “the element starts here”. The closing tag, also called ending tag (</tag>) says the browser, “the element ends here”.

Note that the closing tag starts with a forward slash (/). The tags added around content are known as markup.

Examples of HTML Elements

Some examples of HTML elements are as:

<!--Heading elements-->
<h1>First heading</h1>
<h2>Second heading</h2>

<!--Paragraph element-->
<p>First paragraph</p>

<!--Link element-->
<a href ="">Scientech Easy</a>

Commonly Used HTML Elements

HTML provides a wide range of elements that we can use to create a web page. The most commonly used HTML elements are as follows:

(1) <!DOCTYPE html> Element:

The declaration of DOCTYPE (also known as HTML document type) is the first line of HTML code needed in every HTML web page. The DOCTYPE declaration tells the web browser about what version of HTML page we wrote in.

(2) <html> Element:

HTML element is the root element that is used to specify beginning and ending of HTML code in the document. It is the most fundamental element in which we will use to create a web page. It contains all other elements within. The HTML element consists of a start tag <html> and an end tag </html>.

(3) <head> Element:

The <head> element contains metadata (data about the HTML document). It is placed between the <html> tag and <body> tag. It is not visible to the user.
[adinserter block=”2″]
(4) <body> Element:

This element contains all the contents of an HTML webpage, such as heading, paragraphs, images, links, tables, etc. It consists of a start tag <body> and an end tag </body>. It is the basic structure of a HTML document or web page.

(5) <h1>, <h2>, <h3>, <h4>, <h5>, and <h6> Elements:

These elements create titles and subheadings on a web page. They help to organize content and improve readability.

(6) <p> Element:

The <p> element is used to separate blocks of text and create breaks between sections of content. It consists of a start tag <p> and an end tag </p>. We often use them in combination with headings to create a logical flow of information on a web page.

A basic structure of HTML webpage with these elements is as:

<!DOCTYPE html>
    <title>Introduction to HTML Element</title>
   <h1>Definition of HTML Element</h1>
   <p>A pair of tags and the content inserted between these tags is called HTML element.</p>

In addition to these elements, some other commonly used HTML elements are link, image, list, form, table, title, style, etc. We will understand them in the further tutorial in more detail.

Empty Elements

Empty elements in HTML are those elements that do not have any content. These elements are self-closing, meaning that they do not have a closing tag. Instead, they are closed with a forward slash (/) at the end of the opening tag.

A very simple syntax of an empty element is as:


We commonly use empty elements to add images, links, and other types of content to a web page. Here are some commonly used empty elements in Html:

(1) Image <img/>:

The image element is the most common example of an empty element. We use it to insert images into a web page. It does not contain any content inside of it and is closed with a forward slash at the end of the opening tag. We use an attribute “src” to specify the source of image. Look at a simple example.

<img src ="image.jpg" alt ="An example image" />

(2) Line break <br/>:

This is another empty element that defines a line break in an HTML document. It does not have any content inside it and is closed with a forward slash at the end of the opening tag.

(3) Link <link/>:

This empty element links a web page to an external resource, such as a stylesheet or a favicon. It does not have any content and closes without a closing tag. A simple example of it is as:

<link rel="stylesheet" href="style.css" />

(4) Meta <meta/>:

This empty element defines metadata about a web page, such as the character encoding and keywords. It has no any content inside it and closes with a forward slash at the end of the opening tag.

We specify the metadata in various attributes, such as “charset” and “name”. A simple example of this empty element is as:

<meta charset="UTF-8" />

Nested HTML Elements

HTML also allows to nest elements. When we an element inside other elements, then we call it as nested HTML element. We use nested elements to construct more complex web page layouts and structures.

With the help of nesting elements, we can create hierarchies of content that make it easier to manage and understand webpage structures.

A basic example of nested elements is a structure of the HTML document that contains five HTML elements (<html>, <head>, <body>, <h1> and <p>) as shown above example.

Other examples of nested HTML elements are list elements and table elements. We make a list by nesting list elements (ul, ol, and li) together. An example of list elements is as below:

  <li>Item 1</li>
  <li>Item 2
       <li>Sub-item 1</li>
       <li>Sub-item 2</li>
  <li>Item 3</li>

Types of Elements

There are mainly two basic types of markup elements. They are as:

  • Block element
  • Inline element

We will understand each type in detail with the help of examples in the further tutorials.

In this tutorial, you have known about the HTML elements with various examples. Hope that you will have understood the basic points of elements.
Thanks for reading!!!

⇐ PrevNext ⇒