Empty HTML tags are tags that do not need to be closed when one is creating a HTML document. Some people consider the paragraph tag to be an empty tag, but they are merely non-compliant, dirty-coding fools. The World Wide Web Consortium on the other hand know what they are talking about and try to keep things under control with "compliance", "standards" and other such buzzwords(!)

Anyhoo, here is the official list of empty HTML tags for the 4.01 flava:

AREA
Client-side image map area.

BASE
Document base URL.

BASEFONT
Base font size.

BR
Forced line break.

COL
Table column.

FRAME
Subwindow.

HR
Horizontal rule.

IMG
Embedded image.

INPUT
Form control.

ISINDEX
Single line prompt.

LINK
A media independent link.

META
Generic metainformation.

PARAM
Named property value.

Tech note 1: Although I have written the tag names in uppercase, HTML 4.01 tags are now case insensitive. This is an effort by W3C to bring HTML more in line with XML and persumably to give web developers like myself less headaches.

Tech note 2: As pointed out by Millennium these tags do need to be closed when writing XHTML. See below for further info.

Further info on the joys of HTML 4.01 and can be found at http://www.w3.org.

Note that when using XHTML, these tags do need to be properly closed. There are several ways of doing this:

  • Placing an end tag immediately after the opening tag - An example of this would be <br></br>. There must be nothing between the tags, or the document will fail to validate (although it is still considered well-formed). Although this is perfectly valid XML as well as valid SGML, it tends to create problems in older browsers, which often don't use a true SGML parser to read HTML code.
  • Closing the tag with a slash immediately after the tag name - An example of this practice would be <br/>. This looks more like older HTML, and is, once again, valid. However, some older browsers misread the name of such a tag. The syntax descends from an old SGML shorthand, used to make writing empty tags more convenient.
  • Closing a tag with a slash, using a space - A common example is <br />. This is valid, albeit somewhat strange-looking. However, almost all browsers will read this correctly, because the space signals the end of the tag name and the slash is seen as an invalid attribute (which is ignored). For this reason, this is the preferred format for writing empty HTML tags in XHTML.

Log in or register to write something here or to contact authors.