Differences between XHTML and HTML


XHTML is not very different from the HTML 4.01 standard. So, you can prepare yourself for XHTML by starting to write strict HTML.

The Most Important Differences XHTML Elements Must Be Properly Nested
In HTML, some elements can be improperly nested within each other:

  <b><i>This text is bold and italic</b></i>

In XHTML, all elements must be properly nested within each other:

  <b><i>This text is bold and italic</i></b>

Note that a common mistake with nested lists, is to forget that the inside list must be within <li> and </li> tags. A </li> tag is inserted after the </ul> tag in the correct code example.

Wrong Correct
  <ul>
    <li>Coffee</li>
    <li>Tea
      <ul>
        <li>Black tea</li>
        <li>Green tea</li>
      </ul>
    <li>Milk</li>
  </ul>
  <ul>
    <li>Coffee</li>
    <li>Tea
      <ul>
        <li>Black tea</li>
        <li>Green tea</li>
      </ul>
    </li>
    <li>Milk</li>
  </ul>


Demonstration
The following demonstration shows how the script of HTML is displayed on the Web.