XHTML VS HTML
Since XHTML is evolving from HTML, most of tag can be used interchangeably but there are also some differences. This is the most important ones.
-Elements Must Be Properly Nested
In HTML, impropered nesting would be acceptable, whereas it is not in XHTML. XHTML requires nesting levels to be maintained.For example, in HTML we can use :
<b><i> This is the bold and italic text </b></i> |
<b><i> This is the bold and italic text </i></b> |
-XHTML documents must be well-formed
All XHTML elements must be nested within the <html> root element. All other elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element. The <head> .... </head> and <body> ... </body> tags are mandatory.The basic structure is:
<html> <head> ... </head> <body> ... </body> </html> |
-Tag Names Must Be In Lower Case
While HTML allowed tags to be written in either upper or lower case (for example <BR> or <br>) XHTML only allows lower case tags. This is because XHTML documents are XML applications and XML is case-sensitive.For example, in HTML we can use :
<Font COLOR="red">This is red front </Font> |
<font color="RED">This is red font </font> |
-All XHTML elements must be closed
HTML allows the omission of certain end, or closing, tags (for example <p> without a </p>) where XHTML requires all tags to be closed. Empty elements must either have an end tag or the start tag must end with />.For example, in HTML we can use :
<img src="img.gif"> |
<img src="img.gif" /> |
This tutorial is final project for INFSCI 2000, Fall 2004
Copyright 2004 School of Information Science, University of Pittsburgh