Difference between HTML and XHTML
HTML |
XHTML |
HTML stands for Hypertext Markup Language. It is the language that is used to create webpages and display information in internet browsers. It was first introduced in w3c in the form of HTML 3.2 | XHTML stands for Extensible Hypertext Markup Language. It is the extended version of HTML and used to write in webpages. It belongs to the family of XML |
In the year 1987, Tim Berners-Lee first proposed the concept of HTML. From then onwards it has become one of the most popular web based language | In the year 2000, the World Wide Web Consortium brought the recommended use of XHTML as the more advanced language. It has been extended after the release of HTML 4.0 to compose web based writings |
In case a webpage needs to be created in HTML, it should has a file name extension .html or .htmFor example the webpage name should be saved as ‘index.html’ | XHTML has the filename extension as .xhtml, .xht. For example the webpage name should be saved as ‘index.xhtml’ |
In regards to syntax, HTML is far more marginal in case of error handling. It can terminate uncountable elements | In XHTML the syntax rules are clear and easy to write code.The structure for XHTML is much more standardized.The XHTML format has rules defined such as “Attribute values should be written in quotes”, “attribute and element requires to be in lower case”, “closing tags are must for non-empty elements”. In case of strict HTML, “inline elements should remain in block element”. Thus the language is more precise for the developers to create code |
HTML follows text or html media type | XHTML follows application or (xhtml+xml) internet media type |
It is based on the principals of Standard Generalized Markup Language | XHTML is based on the principals of XML |
The versions of HTML available world wide are HTML 2, HTML 3.2, HTML 4.0, HTML 5. The latest version is HTML5 that has been in used in recent days | The versions of XHTML launched in the market till date are XHTML 1, XHTML 1.1, XHTML 2, XHTML 5 |
HTML has a flexible framework where the only requirement is the HTML parsers that are lenient specific. Thus they are easily handled | On the other hand XHTML consists of restricted subsets of XML. This requires standard XML parsers. So writing a code using XHTML can be a bit tricky and requires standardization |
In HTML there is no concern with the well-formedness constraints. Thus the errors are not fatal. error handling mechanisms are well formatted. It also has well defined recovery management. This is one of the greatest features in HTML that differs it from XHTML | XHTML is concerned with the well-formedness constraints. The errors in XHTML format are fatal. |
In HTML, xml declaration is not required. Moreover the encoding if not specified in declaration may be specified but the implementation heuristics. | XHTML encoding is based on xml rules. Thus the default encoding for XHTML is either UTF-8 or UTF-16 |
As per parsing algorithm the elements and attributes that are present in HTML, SVG and MathML are assigned specific namespace. They mostly contains xmlns attribute when it follows the value https://www.w3.org/1999/xhtml. Foreign elements need to be declared explicitly | In XHTML the HTML elements require namespace based on the rule defined in “Namespaces in XML” specification. Thexmlnsattribute follows the value https://www.w3.org/2000/xmlns. Foreign elements can be independently used |
In HTML names does not depend on case sensitivity. It does not allow attribute minimization | XHTML names are case sensitive. It allows attribute minimization |
CSS has a requirement to specially handle the body elements when HTML needs to set paint in background | XHTML has no such requirement of special handling of body elements |