HTML versus XHTML
XHTML stands for EXtensible HyperText Markup Language. It is a stricter, more XML-based version of HTML.
XHTML is HTML defined as an XML application.
XHTML is supported by all major browsers
XHTML was developed to make HTML more extensible and flexible to work with other data formats (such as XML). Besides, browsers ignore errors in HTML pages, and try to display the website even if it has some errors in the markup. Not so with XHTML.
The Most Important Differences from HTML
- <!DOCTYPE> is mandatory
- The xmlns attribute in <html> is mandatory
- <html>, <head>, <title>, and <body> are mandatory
- Elements must always be properly nested
- Elements must always be closed
- Elements must always be in lowercase
- Attribute names must always be in lowercase
- Attribute values must always be quoted
- Attribute minimization is forbidden
An Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title of document</title> </head> <body> some content here... </body> </html>
[...]