A more XML-based and stringent variant of HTML is called XHTML.
What is XHTML?
EXtensible HyperText Markup Language is known as XHTML.
A more XML-based and stringent variant of HTML is called XHTML.
HTML defined as an XML application is called XHTML.
All of the major browsers support XHTML.
Why XHTML?
Since XML is a markup language, any documents using it must be properly marked up (or “well-formed”).
In order to make HTML more adaptable and extendable to deal with different data formats (like XML), XHTML was developed. Furthermore, browsers attempt to show a website with faults in the markup, disregarding errors in HTML pages. Thus, XHTML has far more stringent error handling.
Read our XML Tutorial if you’d want to learn more about XML.
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
XHTML - < !DOCTYPE ... .> Is Mandatory
An XHTML <!DOCTYPE> declaration is required for an XHTML document.
The xmlns attribute in <html> must identify the xml namespace for the document, and the <html>, <head>, <title>, and <body> elements must also be present.
Example
Here is an XHTML document with a minimum of required tags:
Title of document
some content here...
XHTML Elements Must be Properly Nested
In XHTML, elements must always be properly nested within each other, like this:
Correct:
Some text
Wrong:
Some text
XHTML Empty Elements Must Always be Closed
In XHTML, empty elements must always be closed, like this:
Correct:
This is a sentence
This is another sentence
Wrong:
This is a sentence
This is another sentence
XHTML Elements Must Always be Closed
In XHTML, empty elements must always be closed, like this:
Correct:
This is a sentence
This is another sentence
Wrong:
This is a sentence
This is another sentence
XHTML Empty Elements Must Always be Closed
In XHTML, empty elements must always be closed, like this:
Correct:
A break:
A horizontal rule:
An image:
Wrong:
A break:
A horizontal rule:
An image:
XHTML Elements Must be in Lowercase
In XHTML, element names must always be in lowercase, like this:
Correct:
This is a sentence
Wrong:
This is a sentence
XHTML Attribute Names Must be in Lowercase
In XHTML, attribute names must always be in lowercase, like this: