An Abridged Look at HTML XHTML

Introduction to XHTML

 
XHTML stands for  ”eXtensible  Hyper  Markup  Language”. It is an extended version of HTML 4.01. XHTML is a such HTML which is defined in XML format .Therefore, it is an XML application. XHTML is basically supported by almost all the available major browsers like Internet Explorer, Opera, Safari, and  Chrome.
 
There are many web pages available on the internet that contain “bad HTML” means those don't  follow the actual principle of HTML, but still execute very well.
 
For example
  1. <html>  
  2.     <head>  
  3.         <title>  
  4. This is a bad HTML page  
  5. </title>  
  6.     </head>  
  7.     <body>  
  8.         <h1>Bad HTML   
  9.             <p> This is a web page that contain bad HTML.   
  10.             </body>  
  11.         </html>  
In the above example, it doesn't follow the rule of HTML (ie. Every tag is started with a starting tag and ended with ending tag ) as it doesn't contain ending  tag, but above code will work well , if you run it in the browser.
 
Therefore, XHTML was developed by combining the strength(properties) of HTML and XML.
 
How to convert from HTML to XHTML
  1. < !DOCTYPE> is mandatory in XHTML. So add an XHTML <! DOCTYPE>.
  2. Add an xmlns  attribute to the HTML element of every page.
  3. Change all  element's  name in an HTML page to lowercase format.
  4. Change all empty elements of HTML page in order to obtain XHTML page.
  5. Change all attribute's name in an HTML page to lowercase and then quoted all attribute's values.   
Hence, XHTML is differ from HTML in Document structure, elements and attributes format. 
 
* Document Structure
 
XHTML <! DOCTYPE> , XML namespace attribute in <html> tag, <html>,<head>, <title> and <body> are mandatory.
 
*XHTML Elements
 
->XHTML elements must be properly nested.
-> XHTML elements  must always be closed.
->XHTML elements must in lowercase.
->XHTML documents must have one root element.
 
* XHTML attributes
 
->Attributes name must be in lowercase.
->Attributes values must be quoted.
->Attributes minimization is not allowed.