Not all HTML tags are of the same structure. While most elements require an opening tag, a closing tag, and
contents, some elements – known as void elements – only require an opening tag as they themselves do not contain
any elements. This topic explains and demonstrates the proper usage of void elements in HTML

Void elements

HTML 4.01/XHTML 1.0 Strict includes the following void elements:

  • area – clickable, defined area in an image
  • base – specifies a base URL from which all links base
  • br – line break
  • col – column in a table [deprecated]
  • hr – horizontal rule (line)
  • img – image
  • input – field where users enter data
  • link – links an external resource to the document
  • meta – provides information about the document
  • param – defines parameters for plugins

HTML 5 standards include all non-deprecated tags from the previous list and

Advertisement
  • command – represents a command users can invoke [obsolete]
  • keygen – facilitates public key generation for web certificates [deprecated]
  • source – specifies media sources for picture, audio, and video elements

The example below does not include void elements:

<div>
 <a href="http://stackoverflow.com/">
 <h3>Click here to visit <i>Stack Overflow!</i></h3>
 </a>
 <button >



Notice how every element has an opening tag, a closing tag, and text or other elements inside the opening and
closing tags. Void tags however, are shown in the example below:

<img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png" />
<br>
<hr>
<input type="number" placeholder="Enter your favorite number">

With the exception of the img tag, all of these void elements have only an opening tag. The img tag, unlike any other
tag, has a self closing / before the greater than sign of the opening tag. It is best practice to have a space before the
slash.

Advertisement

Recent Posts

Securing phpMyAdmin Like a Pro: Essential Tips and Tricks

Securing phpMyAdmin is crucial to prevent unauthorized access and protect your databases. Here's a guide…

5 months ago

Pasqal raises $100M to build a neutral atom-based quantum computer

Pasqal, a Paris-based quantum computing startup, today announced that it has raised a $100 million…

1 year ago

Apple in talks with Disney, others on VR content for new headset: Report

Developed with Sony Group Corp, the headset will have two ultra-high-resolution displays to handle the…

1 year ago

Microsoft, Amazon results to highlight softening cloud business

After years of blistering growth, most recently fuelled by remote working and studying during the…

1 year ago

Intel chairman Omar Ishrak steps down

Omar Ishrak had stepped down and the chipmaker appointed board director Frank Yeary as his…

1 year ago

Canada to commercialise world's first photonic-based quantum computer

Canadian Prime Minister Justin Trudeau has announced a new federal investment to build and commercialise…

1 year ago