Difference between HTML5 and XHTML
Key difference: HTML5 is the fifth revision of the HTML standard. HTML stands for HyperText Markup Language. It is a well known mark up language used to develop web pages. The core aims of HTML5 have been to improve the language with support for the latest multimedia. XHTML stands for Extensible HyperText Markup Language. It is a markup language written in XML. Essentially, it is a hybrid between HTML and XML specifically designed for Net device displays. It is HTML defined as an XML application.
HTML5 is the fifth revision of the HTML standard. HTML stands for HyperText Markup Language. It is a well known mark up language used to develop web pages. It has been around for a long time and is commonly used in webpage design. XML or Extensible Markup Language defines a set of rules for encoding documents in a format that can be read by both, human and computer.
HTML is written using HTML elements, which consist of tags, primarily and opening tag and a closing tag. The data between these tags is usually the content. The main objective of HTML is to allow web browsers to interpret and display the content written between the tags. The tags are designed to describe the page content. HTML comes with predefined tags. They allow one to insert images, text, videos, forms and other pieces of content together into a cohesive webpage.
The core aims of HTML5 have been to ‘improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices, such as web browsers, parsers, etc.’ HTML5 supercedes HTML 4, as well as XHTML 1 and DOM Level 2 HTML. Additionally, as of December 2012, HTML5 is W3C Candidate Recommendation.
HTML5 aimed to address the variety of mixture of features introduced by various specifications by various browsers. It also aimed to address the many syntax errors in existing web documents. Additionally, it attempts to define a single markup language that can be written in either HTML or XHTML syntax. It is also backward compatible with the previous HTML versions.
XHTML stands for Extensible HyperText Markup Language. It is a markup language written in XML. It is a collection of XML markup languages that mirror or extend versions of HTML. Essentially, it is a hybrid between HTML and XML specifically designed for Net device displays. It is HTML defined as an XML application.
XHTML uses three XML namespaces that correspond to three HTML 4.0 DTDs: Strict, Transitional, and Frameset. These namespaces are used to qualify element and attributes names by associating them with namespaces identified by URI references. The namespaces also prevent identically custom-named tags, which may be used in different XML documents from being read the same way. Hence, each custom tag is read differently.
XHTML markup must conform to the markup standards defined in a HTML DTD. In fact, XHTML is almost identical to HTML 4.01. However, it is a stricter and cleaner version of HTML 4.01.
As XHTML is in part HTML, it is supported by almost all major browsers. However, in order to be compatible with the said Net devices, XHTML must go through a modularization process. In this, the device designer will specify which elements are supported by using standard building blocks. The content creators can then target these building blocks or modules. These modules conform to certain standards. Hence, XHTML extensibility makes sure that the layout and presentation stays more-or-less the same over various platforms.
Some differences between HTML5 and XHTML:
- XHTML is hybrid between HTML and XML, whereas HTML5 is a version of HTML.
- XHTML and HTML are two different ways of representing markup.
- XHTML is almost identical to HTML 4.01. HTML5 is the latest version of HTML.
- In XHTML, all tags, once opened, must be closed. HTML is less strict.
- XHTML has some restrictions about what tags can be nested inside each other.
- XHTML is stricter version of HTML; HTML5 is an upgrade of HTML.
- XHTML uses XML parsing requirements. HTML uses its own.
- HTML does not have a well-formedness constraint, no errors are fatal. In XHTML, well-formedness errors are fatal.
- In HTML5, one does not need to manually declare the namespace.
- In HTML5, one does not need to add type attributes to script and style elements.
- In HTML5, one must use <!DOCTYPE html>, instead of a long doctype.
- In HTML5, the charset declaration is much simpler.
- In HTML5, one does not have a choice to include or not include a dtd uri in the doctype or a choice between transitional and strict.
- In HTML5, one can use embed if needed.
- XHTML 5 is the XML serialization of HTML 5.
- “[HTML 5] is intended to replace XHTML 1.0 as the normative definition of the XML serialization of the HTML vocabulary."
Image Courtesy: w3.org, app.webeffects.us