XHTML VS HTML

tutorial and example
tutorial and example

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