8

In a tag based language like HTML or XML, there are tags which close themselves without the use of a second tag:

<tag/>

Rather than this:

<tag></tag>

Is there a specific name for tags that close themselves?

Thanks! :)

Lemmings19
  • 1,383
  • 3
  • 21
  • 34
  • There was another answer here, but it has been removed. For reference, this kind of tag is often referred to as a 'self-closing tag'. – Lemmings19 Jul 09 '12 at 21:09
  • 1
    The HTML5 spec does not use the term "empty-element tag". Nor does it use the term "self-closing tag". It does however use the phrase "start tag that is marked as self-closing" and slight variants of several times. Note that in HTML5, the `/` only has any effect when parsing foreign content (i.e. SVG or MathML). In all other cases, it is ignored. – Alohci Jul 09 '12 at 23:43
  • "start tag that is marked as self-closing" isn't terribly easy to say when you are explaining something that revolves around a start tag that is marked as self-closing. After mentioning the start tag that is marked as self-closing a few times, you are going to wish there was a single word for the start tag that is marked as self-closing. :P Saying empty-element tag, or self-closing tag is a little better. I guess I'll have to go with those in the future! This question was here to see if there was a better alternative - guess not! @Alohci Thanks for the info. – Lemmings19 Jul 10 '12 at 15:03
  • Just as an aside, I think the reason HTML5 does not use "empty-element tag" is that the relationship between tags and elements is much more complicated in HTML than in XML. For example, imagine a file whose entire contents are `` Parsed as XML, it returns a DOM with one element called "isindex" with no content. Parsed with an HTML5 parser, it returns a DOM with eight elements, four of which have content, four of which are empty, and none of which is called "isindex"! – Alohci Jul 10 '12 at 15:35

1 Answers1

10

The XML specification refers to them as empty-element tags.

Source:

Definition: An element with no content is said to be empty.] The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. [Definition: An empty-element tag takes a special form:]

Wayne
  • 59,728
  • 15
  • 131
  • 126