How to Work with Empty and Container Tags in HTML

See HTML: Tips and Tricks for similar articles.

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>
or
<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 Ask Good Technical Questions
  2. How to Properly Nest Lists in HTML
  3. How to Install and Use Visual Studio Code for Class
  4. How to Open HTML Files in Your Browser from Visual Studio Code
  5. How to Create a Simple HTML Document
  6. How to Work with Empty and Container Tags in HTML (this article)
  7. How to Mark Up a Citation in HTML
  8. How to Create an HTML Table
  9. How to Force a Refresh of favicon.ico