HTML - XHTML
XHTML is written in XML format.
What is XHTML?
- XHTML stands for Extensible HyperText Markup Language.
- XHTML is almost the same as HTML 4.01.
- XHTML is a stricter and cleaner version of HTML.
- XHTML is defined in the way of XML applications.
- XHTML isJanuary 2001W3C Recommendation Standard published in January 2001
- XHTML is supported by all major browsers.
Why use XHTML?
Many pages on the Internet contain "poor" HTML.
If you view this HTML code in a browser, it runs normally (even though it doesn't follow HTML rules):
XML is a markup language that must be correctly marked and formatted.
If you want to learn XML, please read ourXML Tutorial。
Today's technology industry exists with 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 designed as XML.
The most important difference from HTML:
Document Structure
- The XHTML DOCTYPE isMandatory
- The XML namespace attribute in <html> isMandatory
- <html>, <head>, <title>, and <body> areMandatory
Element Syntax
- XHTML elements mustbe properly nested
- XHTML elements must alwaysbe closed
- XHTML elements mustbe lowercase
- XHTML documents must havea root element
Attribute Syntax
- XHTML attributes must uselowercase
- XHTML attribute values must be enclosed in quotesXHTML attribute minimization is
- prohibited<!DOCTYPE ....> is mandatory
<!DOCTYPE ....> is mandatory
You can find the complete XHTML document type in the tag reference manual of Tutorial.
Add an XHTML <!DOCTYPE> to your webpage.Add the xmlns attribute to each <html> element.
Change all elements to lowercase.
Close all empty elements.
XHTML elements must be properly nested
Enter your URL in the following input box:
AI Thinking...
XHTML elements must have closing tags
Note List
Cancel
Empty elements must have closing tags
correct example:
XHTML elements must be lowercase
incorrect example:
correct example:
Attribute names must be lowercase
incorrect example:
correct example:
Attribute values must be enclosed in quotes
incorrect example:
correct example:
Attribute shorthand is not allowed
incorrect example:
correct example:
How to convert HTML to XHTML
- Add an XHTML <!DOCTYPE> to your webpage:
- Add an xmlns attribute to each html element in your page.
- Change all elements to lowercase.
- Close all empty elements.
- Change all attribute names to lowercase.
- Add quotes to all attribute values.