Доброволците ни все още не са превели статията на Български. Присъединете се и помогнете да свършим тая работа!
Можете да прочетете статията и на English (US).
HTML5 and HTML/XHTML
The HTML5 standard defines both these syntaxes. The MIME type (sent in the HTTP
Content-Type header) indicates the choice of syntax: for XHTML the MIME type will be
This example shows an HTML document and an XHTML document including the appropriate HTTP headers:
HTTP/1.1 200 OK Content-Type: text/html <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>HTML</title> </head> <body> <p>I am a HTML document</p> </body> </html>
HTTP/1.1 200 OK Content-Type: application/xhtml+xml <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>XHTML</title> </head> <body> <p>I am a XHTML document</p> </body> </html>
MIME type versus DOCTYPE
Before HTML5, the two separate specifications defined the two syntaxes (HTML 4.01 Specification and XHTML 1.0 specification). According to the XHTML1 standard, you could use XHTML by declaring a special DOCTYPE. However, no browsers have ever implemented this, and the HTML5 standard has reversed the decision. If your page is sent as
text/html, you are not using XHTML.
Instead, the proper MIME type must be present in the
Content-Type HTTP header. If you only put the MIME type into an HTML meta tag like
<meta http-equiv=…>, it will be ignored and treated like
If you serve your pages as
text/html and believe that you are writing XHTML, you may face several problems, as described in these articles:
- No to XHTML an excellent article from Spartanicus
- Beware of XHTML by David Hammond
- Sending XHTML as text/html Considered Harmful by Ian Hickson
- XHTML's Dirty Little Secret by Mark Pilgrim
- XHTML - What's the Point? by Henri Sivonen
- XHTML is not for Beginners by Lachlan Hunt
Most browsers currently support XHTML, including Firefox, Chrome, Safari, Opera, and Internet Explorer (since IE 9). (Internet Explorer 8 and older browsers instead show a download dialog box for unknown file types when they see an XHTML document with the correct XHTML MIME type.)
Differences from HTML