What do you call tags that need no ending tag?

HtmlTerminology

Html Problem Overview


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?

Html Solutions


Solution 1 - Html

This syntax has a variety of names depending on what language you are using. The best way to find out what it is called is to look at the specification for the specific language.

HTML 4.x

I can't find any mention of this syntax in the HTML 4.x specification. It is not valid syntax.

HTML 5

In the HTML 5 specification the / character (called a SOLIDUS) is valid but has no effect for void elements such as <br />, <hr />, <img />, <input />, etc. and for foreign elements (such as SVG tags) it designates a start tag that is marked as self-closing. It is not a valid syntax for all other tags (such as <button /> mentioned in your question).

> Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.

XML

According to the XML specification it is called an empty-element tag:

> The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag.

XHTML

According to the XHTML specification it is called the minimized tag syntax for empty elements:

> C.2. Empty Elements

> Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents.

> C.3. Element Minimization and Empty Element Content

> Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />).

In general if you want to be precise I would recommend using the names as defined in the appropriate standard. Then if people aren't exactly sure what you mean they can look it up in the standard to find out. However if you don't want to use the name in the standard you are free to call it something else if you want. The important thing is that the people who communicate with you can understand you. I don't think anyone would misunderstand you if you used the term 'self-closing tag' for a tag in an XML document even if the standard officially calls it something else.

Thanks to Alohci for the HTML 5 reference.

Solution 2 - Html

The term is self-closing.

Solution 3 - Html

HTML tags can be of two types. They are

  1. Paired Tags

  2. Unpaired Tags

Paired Tags:

A tag is said to be a paired tag if the text is placed between a tag and its companion tag. In paired tags, the first tag is referred to as Opening Tag and the second tag is referred to as Closing Tag.

Example: <i>This text is in italics. </i>

Note: Here <i> is called opening tag. and </i> is called closing tag.

Unpaired Tags:

An unpaired tag does not have a companion tag. Unpaired tags are also known as Singular or Stand-Alone Tags.

Example : <br> , <hr> etc. These tags does not require any companion tag.

Solution 4 - Html

I've always called them Singleton tags!

Solution 5 - Html

That is called a self closing tag

Solution 6 - Html

I know them as bachelor tags.
e.g. here: http://moodle.cs.huji.ac.il/cs09/file.php/67782/xml-intro.pdf (page 30)

Solution 7 - Html

I've called them self-closing, single tags and monotags, I don't know why I haven't adopted a single term though.

Solution 8 - Html

This sort of Element is an empty element (since it does not contain anything, it just may have attributes). That's the correct way according to the specification, AFAIK. (If the Element is not empty, the Element consists of the opening tag, the closing tag, and the content inbetween.)

Those tags are also called "unpaired", "single", or "bachelor tags". The term "self-closing" I don't like because they don't close themselves any more than other tags, it's still you or your program that puts the "/>" in there.

Solution 9 - Html

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

Solution 10 - Html

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: https://stackoverflow.com/questions/8460993/p-end-tag-p-is-not-needed-in-html

Solution 11 - Html

There are paired and unpaired tags.

Unpaired tags are opened and do not have to be closed. They stand alone.

<img />, <input /> and <button />

Solution 12 - Html

I've seen them referred to as singlet (Which is presumably a short form of single-tag)

Solution 13 - Html

According to here:

> An element consists of a start tag, content, and an end tag.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEmanuil RusevView Question on Stackoverflow
Solution 1 - HtmlMark ByersView Answer on Stackoverflow
Solution 2 - HtmltvanfossonView Answer on Stackoverflow
Solution 3 - HtmlAlpeshView Answer on Stackoverflow
Solution 4 - HtmlJoey EzekielView Answer on Stackoverflow
Solution 5 - HtmlDennis HaarbrinkView Answer on Stackoverflow
Solution 6 - HtmlTrevor View Answer on Stackoverflow
Solution 7 - HtmlAcidSoldierView Answer on Stackoverflow
Solution 8 - HtmlfooView Answer on Stackoverflow
Solution 9 - HtmlPrakash ThangaveluView Answer on Stackoverflow
Solution 10 - HtmlCiro Santilli Путлер Капут 六四事View Answer on Stackoverflow
Solution 11 - HtmlPramendra GuptaView Answer on Stackoverflow
Solution 12 - HtmltroelsknView Answer on Stackoverflow
Solution 13 - HtmlCeleritasView Answer on Stackoverflow