HEMANT SONKER'S BLOG

Saturday, September 27, 2008

Differences Between XHTML and HTML

Differences Between XHTML and HTML
Both HTML 4 and XHTML use precisely the same elements, attributes, and values. The difference between HTML and XHTML is in their respective syntax - the main differences are discussed in this section.
• XHTML requires that all Webpages contain the html, head, and body elements, as well as the DOCTYPE declaration, where as in HTML they are not required.
• XHTML insists on having closing tags for every element, even empty ones, where as HTML often lets you omit them.
• HTML requires that all attributes be enclosed by quotation marks, where as HTML lets you omit quotation marks, but only around attribute values which consist of only letters, numbers and these characters: - (dash), . (period), _ (underscore) and : (colon).
• XHTML is case sensitive, where as HTML is not case sensitive. Furthermore XHTML requires that all enumerated attribute values be lower case.

The question is why we should use xhtml??
By using xhtml ,it has various advantages.Firstly it becomes more consistant ,well structured format, pages can be easily parsed and can be processed by software applications.It helps website much easy to maintain, edit etc.
XHTML adopts official XML standards.The best thing about xhtml is that you can view on pda ,computers ,laptops etc with well structured view without any issue.