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