Well-Formed Documents in XML

HTML allows you to do many things, but the rules are lax in some areas, forcing the browser to fill in the missing pieces. XML is not so forgiving, forcing compliance in the following areas:

  • Every opening tag must have a corresponding closing tag.

  • A nested tag pair cannot overlap with another tag.

  • Tag names are case sensitive.

HTML requires many tags to be paired (for example, a closing tag must appear for each opening tag). However, pairing is optional for some of the tags, and only the opening tag is required. The standard example of this is the paragraph tag (<P>). For example, browsers will accept the following HTML code, which creates three paragraphs:

 <P>The first paragraph is here. <P>The second paragraph ...

Get Sams Teach Yourself XML in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.