English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
XHTML is HTML written in XML format
XHTML stands for Extensible Hypertext Markup Language
XHTML vs HTML 4.01 Almost the same
XHTML is a stricter and purer version of HTML
XHTML is defined as HTML in the way of XML applications
XHTML is 2001 Year 1 W published monthly3C Recommended Standard
XHTML is supported by all mainstream browsers
Many web pages on the Internet contain "poor" HTML.
If viewed in a browser, the following HTML code runs very normally (even though it does not follow HTML rules):
<html> <head> <meta charset="utf-8"> <title>This is a non-standard HTML</title> <body> <h1>Non-standard HTML <p>This is a paragraph </body>
XML is a markup language that must be properly marked and well-formed.
Today's technology industry has some different browser technologies. Some run on computers, while others may run on mobile phones or other small devices. Small devices often lack the resources and capabilities to interpret "poor" markup languages.
So - By combining the strengths of XML and HTML, XHTML was developed. XHTML is a re-designed HTML as XML.
document structure
The XHTML DOCTYPE ismandatory
The XML namespace attribute in <html> ismandatory
<html>, <head>, <title>, and <body> are alsomandatory
element syntax
XHTML elements mustcorrectly nested
XHTML elements must alwaysclosed
XHTML elements mustin lowercase
An XHTML document must havea root element
attribute syntax
XHTML attributes must usein lowercase
XHTML attribute values must beEnclosed in quotes
XHTML attribute minimization is alsoProhibited
An XHTML document must have an XHTML document type declaration (XHTML DOCTYPE declaration).
You can find a complete XHTML document type.
The <html>, <head>, <title>, and <body> elements must also be present, and the xmlns attribute in <html> must be used to define the XML namespace for the document.
The following example demonstrates an XHTML document with the minimum required tags:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <title>Document title</title> </head> <body> Document content </body> </html>
In HTML, some elements can be nested without nesting, like this:
<b><i>Bold and italic text</b></i>
In XHTML, all elements must be properly nested, like this:
<b><i>Bold and italic text</i></b>
Incorrect example:
<p>This is a paragraph <p>This is another paragraph
Correct example:
<p>This is a paragraph</p> <p>This is another paragraph</p>
Incorrect example:
Line break:<br Horizontal line: <hr> Image: <img src="happy.gif" alt="Happy face">
Correct example:
Line break:<br /> Horizontal line: <hr /> Image: <img src="happy.gif" alt="Happy face" />
Incorrect example:
<BODY> <P>This is a paragraph</P> </BODY>
Correct example:
<body> <p>This is a paragraph</p> </body>
Incorrect example:
<table WIDTH="100%">
Correct example:
<table width="100%">
Incorrect example:
<table width=100%>
Correct example:
<table width="100%">
Incorrect example:
<input checked> <input readonly> <input disabled> <option selected>
Correct example:
<input checked="checked"> <input readonly="readonly"> <input disabled="disabled"> <option selected="selected">
Add an XHTML <!DOCTYPE> to your webpage
Add the xmlns attribute to each HTML element on each page.
Change all elements to lowercase
Close all empty elements
Change all attribute names to lowercase
All attribute values should be quoted