DEVFYI - Developer Resource - FYI

What about the need for end tags?

XHTML Interview Questions and Answers


(Continued from previous question...)

9. What about the need for end tags?

Remember that XHTML is an XML application.
Have a look at the markup fragments in the following table.

Markup Comments
<part-number>273</part-number>
wheel
Invalid XML
<part-number>273</part-number>
<part-type>wheel</part-type>
Well-formed XML
<h1>Introduction</h1>
Welcome to this document on XHTML.
Valid HTML but invalid XHTML
<h1>Introduction</h1>
<p>Welcome to this document on XHTML.</p>
Valid HTML and well-formed XHTML

Since XML documents can use arbitrary elements an XML application cannot know how the document is structured. Web browsers, however, do know something about the document structure. For example, text that occurs immediately after a heading is normally assumed to be part of a paragraph, and a <p> element is assumed. XML applications can't make such assumptions, so more rigourous markup is required.
Since XML documents can use arbitrary elements an XML application cannot know how the document is structured. Web browsers, however, do know something about the document structure. For example, text that occurs immediately after a heading is normally assumed to be part of a paragraph, and a <p> element is assumed. XML applications can't make such assumptions, so more rigourous markup is required.

(Continued on next question...)

Other Interview Questions