Skip to main content

Empty Tag and Container Tag

Types of Tags​

  1. Empty Tag (Self-Closing Tag)

An empty tag is an HTML tag that doesn't require a separate closing tag because it doesn't have any content or nested elements. These tags are used to insert specific elements or formatting into your HTML structure. One common example of an empty tag is the <br> tag, which is used to create a line break within the content. Here's an example:

My Name is Jadoo.<br />I Lost My Spaceship.

In the above example, the <br> tag doesn't have a closing tag because it's an empty tag.

Empty Tag is also known as a self-closing tag when they are used in the following syntax:

My Name is Jadoo.<br />I Lost My Spaceship.
note

The Output in both the cases will be same and unaffected.

Other examples of empty tags include:

  • <img>: Used to display images.
  • <input>: Used to create input fields.
  • <link>: Used to link external resources like stylesheets.
  1. Container Tag

A container tag, also known as a paired tag or an opening and closing tag, is an HTML tag that consists of both an opening tag and a corresponding closing tag. Container tags are used to enclose and define a block of content or a group of nested elements. The content between the opening and closing tags is affected by the tag's purpose. For example, the <b> tag is used to make text bold, and the <body> tag defines the main content of an HTML document.

<b>This text is bold.</b>

In the above example, the <b> tag is a container tag, with an opening tag <b> and a closing tag </b>.

Other examples of container tags include:

  • <div>: Used to group and style content.
  • <p>: Used to define paragraphs of text.
  • <h1>, <h2>, ..., <h6>: Used to define headings of different levels.
  • <ul>: Used to create an unordered (bulleted) list.
  • <ol>: Used to create an ordered (numbered) list.