Closing Empty Elements (was Re: / )

by "Dennis J Keibler" <dennisk(at)louisville.edu>

 Date:  Sun, 14 Nov 2004 20:40:43 -0500
 To:  <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
>>> David Kendall <david(at)homepagesplus.com> 11/14/04 7:26 PM >>>
I have come across the codes <br /> and <hr /> before, what does 
the extra / symbolize?  


That's a question that probably gets asked a lot. Especially when people
start paying close attention to how their pages are coded. 

The  practice of including the slash in certain tags comes into play
when deciding your web page should be an xml document instead of just an
html document. And xhtml is the resulting "reformulation of HTML 4 as an
XML 1.0 application." ( see http://www.w3.org/TR/xhtml1/ )

With some elements, like an html paragraph tag, it's easy to indicate
where the end of the element should be, and a closing </tag> gets
inserted. But with other elements, such as line breaks and line rules,
it's not applicable to have html closing tags to indicate the end of the
element. Those are known as empty elements.

The W3C website states that because XHTML is an XML application, certain
practices must be changed. One of those practices involves how code is
written for Empty Elements. "Empty elements must either have an end tag
or the start tag must end with />. For instance, <br/> or <hr></hr>." 
Adding a closing tag for every open tag is technically okay, but
including the closing slash at the end of the open element tag is a
"shortcut" that has the same meaning. 

For compatibility across multiple broswers and web enabled devices, the
space is added right before the closing slash.

There are many xhtml tutorials on-line, and you can probably find
additional info in the hwg archives.

Good luck with the xhtml.
--
Dennis K

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA