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.