Types of HTML tags

Types of HTML tags

HTML Tags

A web page is made up of several elements such as the title of the page, headings in the page (like in a newspaper), written text, paragraphs and images. Each element is defined by an HTML tag. An HTML tag is nothing but a label added to the text that is to be shown on the web page. These labels or tags tell the web browser where particular text is to be displayed and how it is to be displayed. HTML tags are always enclosed in angle brackets, that is, < >.

There are two types of HTML tags:

Container tags

HTML tags that are generally used in pairs are called container tags as these tags are written with some text between the first and the second tags. The first tag is called a Start tag or ON tag and the second tag is called an End tag or OFF tag. The End tag is created by simply placing a forward slash (/) in front of the Start tag. Examples of container tags are as follows.

Start tag                   End tag

<title>                        </title>

<head>                      </head>

Empty tag

Empty tags are those that do not need an End tag. They are not used in pairs and are represented only by a Start tag or ON tag. Examples of empty tags are the line break tag <br> and the horizontal ruler tag <hr>.

Nested tags

You can start using another tag without closing the first tag. This means that one tag can contain other tags also. Such tags are known as nested tags.

You must remember that when you start closing such tags, the tag that has been opened last should be closed first. It is not important which tag is opened first, but it is very important which tag should be closed first. For example,

  • <body> <p> <h1> This is not a proper way to close nested tags </p> </body> </h₁>
  • <body> <p> <h1> This is the proper way to close nested tags </h1> </p> </body>