XHTML Introduction
XHTML is an XML format written in HTML.
What is XHTML?
- XHTML refers to the Extensible HTML
- XHTML and HTML 4.01 are almost identical
- XHTML is stricter and more pure HTML version
- XHTML application by way of XML defined HTML
- XHTML is the January 2001 W3C Recommendation published
- XHTML by all major browsers support
Why use XHTML?
Internet page contains a lot of "bad" HTML.
If you look in a browser, the following HTML code to run very normal (even if it does not comply with HTML rules):
XML is a must properly marked and well-formed markup language.
If you want to learn XML, please read our XML Tutorial .
Today, the scientific community, there are some different browser technology. Some of which run on a computer, while others may run on mobile phones or other small devices. Small devices often lack explain "bad" markup language resources and capabilities.
So - by combining the strengths of HTML and XML, we developed XHTML. XHTML as XML redesigned HTML.
The most important difference compared with the HTML:
Document Structure
- XHTML DOCTYPE is mandatory
- <html> The XML namespace attribute is mandatory
- <html>, <head>, <title> and <body> is mandatory
Element Syntax
- 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
Attribute syntax
- XHTML attributes must be lowercase
- XHTML attribute values must be surrounded by quotation marks
- XHTML attribute minimization is forbidden
<! DOCTYPE /en/en> is mandatory
XHTML documents must be XHTML document type declaration (XHTML DOCTYPE declaration).
You can find the complete tutorial in this tag in the Reference Manual XHTML document type.
<Html>, <head>, <title>, and <body> element must exist, and must use <html> xmlns attribute in the document specified xml namespace.
The following example shows an XHTML document with a minimum of required tags:
XHTML elements must be properly nested
In HTML, some elements can not be nested, like this:
In XHTML, all elements must be nested with each other rational, like this:
XHTML elements must have a closing tag
Examples of errors:
Right:
Empty elements must include a closing tag
Examples of errors:
Right:
XHTML elements must be in lowercase
Examples of errors:
Right:
Attribute names must be lowercase
Examples of errors:
Right:
Attribute values must have quotes
Examples of errors:
Right:
Allowed shorthand property
Examples of errors:
Right:
How to Convert HTML to XHTML
- Add a XHTML <! DOCTYPE> to your page
- Adding xmlns attribute to the html element of every page.
- Change all the elements to lowercase
- Close all empty elements
- Modify all attribute names to lowercase
- All attribute values to add quotes