List of HTML Self-Closing Tags

By Xah Lee. Date: . Last updated: .

Some tags does not need a closing tag. For example, the img tag:

<img src="my_cat.jpg" alt="my cat" width="677" height="409" />

There's no </img>

Here's a complete list of self-closing tags for HTML5. These are called “void-elements” in HTML spec.

<area />
<base />
<br />
<col />
<command />
<embed />
<hr />
<img />
<input />
<keygen />
<link />
<menuitem />
<meta />
<param />
<source />
<track />
<wbr />

The space before the slash is optional.

Is the Ending Slash Optional?

I recommend to always add the slash. Because, it provides a visual clue of non-closing tags.

XHTML Supports Self-Closing Syntax for All Tags

In XML/XHTML, any tag can be self-closed by the ending slash <… />.

When you test XML, you have to make sure the server is sending the correct Internet media type as XHTML (For example, application/xhtml+xml), otherwise browsers will treat it as HTML, regardless of the DOCTYPE in your file.

Reference

https://www.w3.org/TR/html/syntax.html#void-elements

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon