HTML Tags Overview: Paired and Unpaired Tags
What is HTML Tag?
HTML Tag is pre-defined element in HTML, enclosed within these brackets <>
sign. For example: <html>
, <table>
, etc. All HTML tags has particular function associated with them.
Each tag has a special function and a combination of various tags developes a website. i.e. <p>
tag define a paragraph in the website and a <table>
tag display a table.
All HTML tags are predefined, i.e, you cannot create new tags. Look at the example below, this is paired tag. Observe that there are two tags of same name, but the latter one has a slash /
before it, it is a closing tag.
<p>
Here is a paragraph of text.
</p>
Types of tags in HTML
There are two types of tags in HTML:
- Paired Tags (Opening and Closing Tags)
- Unpaired Tags (Singular Tag)
Paired Tags - Opening and Closing Tags
Paired tags are a set of two tags with the same name. In each Paired tag set, one is an opening tag, and the other one is the closing tag. The closing tag has a /
slash, it means that the tag is closed now.
It is necessary to close a paired tag; otherwise, it can result in the malfunctioning of the website. When the content is written within paired tags, then it ensures that the effect of those tags would be limited to only the content between them.
Look at the list of some paired tags in HTML below. Notice that each tag has a closing tag with a slash(/)
before the name of the tag.
<tag>Content......</tag>
List of some paired tags in HTML:
Opening Tag | Closing Tag |
---|---|
< html > | < /html > |
< body > | < /body > |
< head > | < /head > |
< div > | < /div > |
< p > | < /p > |
< form > | < /form > |
< span > | < /span > |
< ul > | < /ul > |
Unpaired Tags - Self closing Tags
Unpaired tags are single tags with no closing tag. These tags are also called Singular Tags. These are also called non-container tags because they do not contain any content.
It is recommended to close the unpaired/singular tags also. But unfortunately, we do not have the closing tag for those. So, an unpaired tag is closed after adding a slash(/)
just before the greater than >
sign. For example: <br />
.
List of Some Unpaired/Self closing Tags are:
Opening Tag |
---|
< br > |
< hr > |
< meta > |
< input > |
< img > |