DOM - HTML vs XML document


The DOM specification gives the distinction between this two type of document:



HTML elements are rarely nested.

In a XML file, the subsection (SECT) can be totally contained within the major section (SECT). They are nested.

<?xml version="1.0"?>
   <TITLE>A Sample Article</TITLE>
   <SECT>The First Major Section
      <PARA>This section will introduce a subsection.</PARA>
      <SECT>The Subsection Heading
         <PARA>This is the text of the subsection.

In HTML, on the other hand, headings do not contain the body of a section.

   <H1>The First Major Section</H1>
      <P>This section will introduce a subsection.</P>
      <H2>The Subsection Heading</H2>
         <P>This is the text of the subsection.</P>


HTML goes down only to five levels.


The following are not valid in XML/XHTML

<!-- valid HTML, non XML valid -->
<meta name="generator" content="datacadamia">
<!-- valid XHTML -->
<meta name="generator" content="datacadamia"/>

Powered by ComboStrap