-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
55 lines (43 loc) · 1.42 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
title: XHTML
slug: Glossary/XHTML
page-type: glossary-definition
---
{{GlossarySidebar}}
**XHTML** is a term that was historically used to describe [HTML](/en-US/docs/Web/HTML) documents written to conform with {{Glossary("XML")}} syntax rules.
The following example shows an HTML document and corresponding "XHTML" document, and the accompanying {{Glossary("HTTP")}} {{HTTPHeader("Content-Type")}} headers they should be served with.
### HTML document
```html
<!-- Content-Type: text/html -->
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>HTML</title>
</head>
<body>
<p>I am a HTML document</p>
</body>
</html>
```
### XHTML document
```xml
<!-- Content-Type: application/xhtml+xml -->
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>XHTML</title>
</head>
<body>
<p>I am a XHTML document</p>
</body>
</html>
```
In practice, very few "XHTML" documents are served over the web with a `Content-Type: application/xhtml+xml` header. Instead, even though the documents are written to conform to XML syntax rules, they are served with a `Content-Type: text/html` header — so browsers parse those documents using HTML parsers rather than XML parsers.
## See also
- Related glossary terms:
- {{Glossary("HTML")}}
- {{Glossary("HTML5")}}
- {{Glossary("SVG")}}
- {{Glossary("MathML")}}
- {{Glossary("XML")}}