What are HTML and XHTML?
Hyper Text Markup Language (HTML) is a kind of markup language for displaying web pages and other information that can be displayed in a web browser. Contents are enclosed in tags. Actually webpage is a kind of text file, so we can tell the web browsers how to display contents by adding different kinds of tags in it. The reason why this language is called hyper is probably because we can make hyperlinks in text file, which are URL pointers. By activating these, usually clicking, you can get access to new webpages.
Extensible Hyper Text Markup Language (XHTML) is also a kind of markup language. However it is based on XML, while HTML is based on SGML. Since XML is a restrictive subset of SGML, to some extent. XHTML is very similar to HTML and it can be viewed as a successor of HTML.
Difference between HTML and XHTML
Although XHTML is called extensible, actually its grammars are more rigorous than HTML. The grammar of HTML is flexible and this is convenient for webpage designing. But the more flexible the grammar is, the more difficult for machine to process it. It is not a big problem for computers, which have a good compatibility, so in a few years ago HTML is very popular for people to write webpage. But with the development of terminals, we are more likely to use mobile terminals to search the Internet, for example, cell phones, which have a comparatively worse compatibility, and it has become a big problem. So XHTML, a language with more strict grammars, becomes increasingly commonly used in recent years.
Attributes names must be in lower case according to XHTML standard, but there is no restriction about attributes name in HTML. And in XHTML letters in capital form and in lower case is treated differently, for example, <title> and <Title> are different tags, while they are the same in HTML standard.
Values of attributes should be enclosed by a pair of double quotations or single quotations when using XHTML, while in HTML values of attributes can be enclosed by quotations or single quotations or even without quotations, for instance:
Incorrect in XHTML: <table rows = 3>
It should be <table rows = “3”>
Attributes and their values must be used in pair in XHTML, which means you can not minimized attributes, but you can do this when writing codes of HTML, for example:
Incorrect in XHTML: <input checked>
It should be <input checked=”checked”>
Elements of XHTML should be enclosed by a pair of flags, however in HTML there is not always needed, for example:
Incorrect in XHTML: <p>this is a paragraph
It should be <p>this is a paragraph </p>
Elements of XHTML should be enclosed in a properly nesting order, while in some versions of HTML there is no such need, for example,
Incorrect in XHTML: <p><span>text content</p></span>
It should be <p><span>text content</span></p>
There are only a few but very important differences between HTML and XHTML. We can view XHTML is a XML-version of HTML, which can meet all the need of XML standard and have more restriction on grammar.