What do you call tags that need no ending tag?

Viewed 49659

There are HTML tags, such as <img />, <input /> and <button />, that need no ending tag (</img>, </input> and </button>). What is the term that describes this type of tags?

13 Answers

Those tags are called "Standalone Tags". Standalone tags are having no closing tags in HTML

But in XHTML they have to be self closed by adding forward slash before the closing angular bracket

Optional closing tags like p, li, etc.

It is also worth mentioning that several other tags besides those mentioned in the question don't need a closing tag: they just close automatically when something specified in the standard appears.

For example:

<body>
<p>abc
<p>def
</body>

is equivalent to:

<body>
<p>abc
</p>
<p>def
</p>
</body>

because the p closes both at:

  • the start of another p
  • when the parent of the p closes

This is specified at 12.1.2.4 "Optional tags" https://html.spec.whatwg.org/multipage/syntax.html#optional-tags but I don't think there's an actual name besides "an element with an optional closing tag".

See also: P-end-tag (</p>) is not needed in HTML

Related