How to Work with Empty and Container Tags in HTML

See HTML: Tips and Tricks for similar articles.
Looking to improve your HTML skills? Check out Webucator’s HTML classes.

Generally speaking, HTML has two types of tags: empty and container. In this how-to, you'll learn the difference between the two.

Most HTML elements consist of a starting tag, an ending tag, and everything that comes between the two tags, which is known as the element's contents. Here's an example of an element with a starting tag, and ending tag, and content:

<p>Hello, world!</p>

When tags are part of an element that can have content, the tags are called container tags.

Some elements only have a single tag and therefore can't have any content. These elements are called empty elements or empty tags.

Empty elements have the following syntax:

<tagname att1="value" att2="value">

The empty elements are:

  • <area>
  • <base>
  • <br>
  • <col>
  • <embed>
  • <hr>
  • <img>
  • <input>
  • <link>
  • <meta>
  • <param>
  • <source>
  • <track>
  • <wbr>

Related Articles

  1. How to Properly Nest Lists in HTML
  2. How to Open HTML Files in Google Chrome from Visual Studio Code
  3. How to Create a Simple HTML Document
  4. How to Work with Empty and Container Tags in HTML (this article)
  5. How to Mark Up a Citation in HTML
  6. How to Create an HTML Table
  7. How to Force a Refresh of favicon.ico