HTML 4.01/XHTML 1.0 Strict includes the following void elements:
area - clickable, defined area in an imagebase - specifies a base URL from which all links basebr - line breakcol - column in a table [deprecated]hr - horizontal rule (line)img - imageinput - field where users enter datalink - links an external resource to the documentmeta - provides information about the documentparam - defines parameters for pluginsHTML 5 standards include all non-deprecated tags from the previous list and
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 elementsThe example below does not include void elements:
<div>
<a href="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3Bhttp%3A%2F%2Fstackoverflow.com%2F%26quot%3B%26gt%3B%2520%2520%2520%2520%2520%2520%2520%2520%26lt%3Bh3%26gt%3BClick%2520here%2520to%2520visit%2520%26lt%3Bi%26gt%3BStack%2520Overflow!%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fh3%26gt%3B%2520%2520%2520%2520%26lt%3B%2Fa%26gt%3B%2520%2520%2520%2520%26lt%3Bbutton%2520onclick%3D%26quot%3Balert("Hello!');">Say Hello!</button>
<p>My favorite language is <b>HTML</b>. Here are my others:</p>
<ol>
<li>CSS</li>
<li>JavaScript</li>
<li>PHP</li>
</ol>
</div>
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="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3Bhttps%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2Fcompany%2Fimg%2Flogos%2Fso%2Fso-icon.png%26quot%3B%2520%2F%26gt%3B%26lt%3Bbr%26gt%3B%26lt%3Bhr%26gt%3B%26lt%3Binput%2520type%3D%26quot%3Bnumber%26quot%3B%2520placeholder%3D%26quot%3BEnter%2520your%2520favorite%2520number%26quot%3B%26gt%3B%253C%2Fcode">
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.