XHTML VS HTML

XHTML is different from HTML and has certain rules that are divided into three parts:

  • Changes in Document Structure
  • Changes in XHTML Tags
  • Changes in XHTML Attributes

Changes in Document Structure

  • XHTML documents must have a DOCTYPE
  • These tags (<html>,<head>,<title> and <body>) are mandatory with their closing tags in XHTML
  • xmlns attribute is required in XHTML

Changes in XHTML Tags

    • Tags must be in lower case
    • Tags must be closed
    • Tags must be properly nested
XHTML documents must have one root element

Changes in XHTML Attributes

  • Attributes must be in lower case
  • Attributes cannot be shortened
  • Attribute values must be quoted
  • Attributes must be added properly
Example of a Simple XHTML document
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">    
<head>    
  <title>Title</title>    
</head>    
<body>    
  CONTENT??..  
</body>    
</html>