XHTML 1.0 DocType ignored in all browsers?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-01-26T22:58:50Z Indexed on 2010/06/13 18:52 UTC
Read the original article Hit count: 162

Filed under:
|

I was testing this, since I understood using XHTML let me use any valid XML for empty <div> elements:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Test</title>
</head>

<body>
<div style="border:solid 10px black; width:100px; height:100px"></div>
<div style="border:solid 10px red; width:100px; height:100px"></div>
<div style="border:solid 10px blue; width:100px; height:100px"></div>

<div style="border:solid 10px black; width:100px; height:100px" />
<div style="border:solid 10px red; width:100px; height:100px" />
<div style="border:solid 10px blue; width:100px; height:100px" />
</body>
</html>

It doesn't work in any browser I try... this is how FireBug tells me it understands the document:

<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<title>Test</title>
</head>
<body>
<div style="border: 10px solid black; width: 100px; height: 100px;"/>
<div style="border: 10px solid red; width: 100px; height: 100px;"/>
<div style="border: 10px solid blue; width: 100px; height: 100px;"/>
<div style="border: 10px solid black; width: 100px; height: 100px;">
 <div style="border: 10px solid red; width: 100px; height: 100px;">
  <div style="border: 10px solid blue; width: 100px; height: 100px;"/>
 </div>
</div>
</body>
</html>

I'm a bit confused what the point is of using XHTML if I have to do this, I might as well just use HTML?

Note, that setting the content type to content="application/xhtml+xml" makes no difference in FF3 at least.

© Stack Overflow or respective owner

Related posts about html

Related posts about XHTML