What is the exact difference between HTML and XHTML?
I have seen related posts here, but I am not getting it exactly.
XHTML is not so much different from HTML 4.01 standard. The major differences are:
- XHTML elements must be properly nested.
- XHTML elements must always be closed.
- XHTML elements must be in lowercase.
- XHTML documents must have one root element.
Basically, XHTML is HTML (all the html tags are found in XHTML) that follows the rules of XML (because it is a family of XML).
More references can be found on:
- W3Schools.
- Wikipedia.
- Sitepoint.com.
XHTML is an application of XML, which is quite a strict angle-bracket language.
HTML is an application of SGML, which is a much less strict angle-bracket language.
(XML is also an application of SGML.)
At one time, people hoped that the solution to the mess of the late 90s web markup was to persuade everyone to write XHTML rather than HTML, perhaps in the hope that the enforced discipline would transform all those polo-necked frameless-spectacle wearing graphic designers into computer programmers. Alas, there was not actually much demonstrable benefit to all this exhausting prostration at the altar of the XHTML validator, so XHTML is now out of fashion and HTML is back in.
XHTML will be treated an application of XML only in case where MIME type application/xhtml+xml, application/xml, or text/xml are used. An XHTML document served with a MIME type of text/html must be parsed and interpreted as HTML, so the HTML rules apply in this case.
Check this link for more on difference between XHTML and HTML
- XHTML is case sensitive, different from HTML.
- XHTML's tags must be opened and closed different from HTML where a tag can be left as open.
- XHTML is not browser-dependent and can run on any browser platform, unlike HTML.
精彩评论