Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct terminology for an HTML/XML tag that closes itself?

Tags:

html

xml

xhtml

tags

I can't remember the term that is used to describe the difference between an html tag that is self-closing,

For example, <hr /> closes itself.

<p>This doesn't</p>

like image 266
smartcaveman Avatar asked Jun 15 '11 21:06

smartcaveman


2 Answers

The term used by the XML specification is:

Empty-element tag

The relevant part of the specification says:

Tags for Empty Elements

[44]  EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]

Empty-element tags may be used for any element which has no content, whether or not it is declared using the keyword EMPTY. For interoperability, the empty-element tag SHOULD be used, and SHOULD only be used, for elements which are declared EMPTY.

However, you might also frequently hear the term self-closing tag.

like image 193
Dirk Vollmar Avatar answered Sep 19 '22 16:09

Dirk Vollmar


I have always used the term "self-closing tag". I didn't know there was another term!

like image 23
James Allardice Avatar answered Sep 23 '22 16:09

James Allardice