How to Work with Empty and Container Tags in HTML

  • google plus

In Brief...

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

Take our Introduction to HTML Training course for free.

See the Course Outline and Register

Instructions

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>

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.

Categories

Courses

Author: Chris Minnick

Chris is a prolific author and trainer, and the CEO of WatzThis?. His published books include Writing Computer Code, JavaScript for Kids, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW eCommerce Certification Bible, and New Riders' XHTML.

Discuss