Differences Between HTML and XHTML

XHTML is not very different from the HTML.

The most important difference between the two markup languages is that HTML (HyperText Markup Language), is an application of SGML (Standard Generalized Markup Language) and allows to omit certain tags and use attribute minimization. The XHTML (Extensible HyperText Markup Language), is an application of XML (Extensible Markup Language) and it doesn’t permit the omission of any tags or the use of attribute minimization.

The Main Differences are:

  • XHTML elements must be properly nested
  • XHTML elements must always be closed
  • XHTML elements must be in lowercase
  • XHTML documents must have one root element

Some examples of XTML are given below:

Wrong Method

<p>This is a paragraph
<p>This is another paragraph

Correct Method

<p>This is a paragraph</p>
<p>This is another paragraph</p>

Wrong Method

A break: <br>
A horizontal rule: <hr>
An image: <img src=”happy.gif” alt=”Happy face”>

Correct Method

A break: <br />
A horizontal rule: <hr />
An image: <img src=”happy.gif” alt=”Happy face” />