Reputation: 1523
I started learning the basics of HTML and I have studied differences between XHTML and HTML. I have noticed XHTML is much stricter. Consider below markup
<?xml version="1.0" encoding="UTF-8"?>
<!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/TR/xhtml1" xml:lang="en" lang="en">
<head>
<title>Every document must have a title</title>
</head>
<body>
<b><p>hey</b></p><br>
</body>
</html>
I have not properly nested the tags and <br>
is not properly closed in XHTML but it does not raise any parsing error and when I have saved the file as test.xhtml
then it raised parsing error. So how to actually create XHTML files and also how to use XHTML in HTML5? and could anyone explain me that files saved with .xhtml
are XHTML files and with .html
are treated as HTML files?
Iam using google chrome. I understand the differences but unable to view practically in the browser. Could anyone help me figuring this out.
Upvotes: 0
Views: 106
Reputation: 943801
Most web browsers have XML and HTML parsers. These use different rules.
In general, the rules they follow are:
text/html
content-type then use the HTML parser.xhtml
file extension, then treat it as having the content-type application/xhtml+xml
.html
file extension, then treat it as having the content-type text/html
Upvotes: 2