Void elements

Last updated October 1, 2021 by Jacob Paris

HTML has several void elements.

  • <br>
  • <hr>
  • <img>
  • <input>
  • <link>
  • <meta>
  • <area>
  • <base>
  • <col>
  • <embed>
  • <param>
  • <source>
  • <track>

These cannot have any content, and cannot have separate closing tags. Closing a void element like this is invalid html.

<img alt></img>

Void elements can optionally be self-closing, so these are both correct.

<!-- prettier-ignore -->
<img alt>
<img alt />