5. XHTML Element Closure

Non-empty elements are required to have an end element.

Example 5.1 Incorrect Non-Empty Element Closure
<p>Sample paragraph.
Example 5.2 Correct Non-Empty Element Closure

Empty elements are required to have either an ending element or must be self closing.

Example 5.3 Incorrect Empty Element Closure
<img src="image.gif alt="">
Example 5.4 Correct Empty Element Closure
<img src="image.gif alt="" />

For browser compatibility it is recommended to add an extra white space before the "/" symbol. Some older browsers cannot process a self closing element without a space.

Example 5.5 Non-recommended Empty Elemenent Closure without Whitespace
<input type="test"/>
Example 5.6 Recommended Empty Elemenent Closure with Whitespace
<input type="test" />