The purpose of XHTML
Why was XHTML implemented? Was HTML not enough to generate content on webpages? XHTML serves an important purpose on the world wide web.
This lesson focuses on:
- The purpose of XHTML
The purpose of XHTML
Many pages on the world wide web contain what is deemed as bad HTML. It is said to be as such because of certain errors within the code such as missing closing tags.
Example:
<html> <head> <title>Page with an error</title> </head> <body> <b>This text is bold </body> </html>
Do you notice the error in the above HTML code? It is found in the line of code <b>This text is bold. There is no closing </b> tag. Even though there is an error, the code will still work in browsers, though some of the content may not be displayed as you intend it to.
This is where XHTML comes into the picture. Though it is a language almost identical to HTML 4.01, XHTML is in fact a hybrid language - it is a combination of HTML and XML.
XML is a markup language where everything must be marked up correctly with tags resulting in what are called "well-formed" documents, it is a language used to describe data. HTML is a markup language used to display content on webpages, it is a language used to display data. XHTML is therefore a combination of XML and HTML - it is used to display content on webpages, and it must be marked up correctly with tags resulting in "well-formed" documents.
There are many different browsers in use today. Some which run on PC's and Mac's, and others that run on mobile phones and other hand held devices. The latter do not have the power to interpret bad HTML, therefore XHTML is useful for creating web pages since it is used to display content on webpages, as well as avoids the problem of bad HTML.




