XHTML1.0 vs XHTML 1.1

good,just want going to learn xml :slight_smile:

Have a few references/tutorials that could be of interest:

XHTML 1.1 Tutorial
XHTML Basic 1.0 Tutorial
XHTML Basic for mobile devices(what is XHTML Basic?)
XHTML - A combination of HTML and XML

Also, for those interested in using strict markup with XHTML in combination with Adsense, you should know there is a problem with Content-Type application/xhtml+xml.
According to w3c XHTML should be sent as application/xhtml+xml. There is allowed, however, to use text/html on less strict modules such as XHTML Transitional.

Since older browsers and IE doesn’t understand application/xhtml+xml they can react by displaing the source code or not showing the document at all.

Therefor, to use application/xhtml+xml it is best to let the server know if a client/browser requesting a page can handle application/xhtml+xml, and - if the browser doesn’t handle it - send it as text/html.

If PHP is used the following script can be used to send the different content types to different browsers:

<?php
if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml") ||
stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
    header("Content-Type: application/xhtml+xml; charset=iso-8859-1");
    header("Vary: Accept");
    echo("<?xml version=\\"1.0\\" encoding=\\"iso-8859-1\\"?>\
");
    }
else {
    header("Content-Type: text/html; charset=iso-8859-1");
    header("Vary: Accept");
    }
?>

If ASP and VBScript is used:

<%
If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/xhtml+xml") > 0
Or InStr(Request.ServerVariables("HTTP_USER_AGENT"), "W3C_Validator") > 0 Then
    Response.ContentType = "application/xhtml+xml"
    Response.Write("<?xml version=""1.0"" encoding=""iso-8859-1""?>" & VBCrLf);
Else
    Response.ContentType = "text/html"
End If
Response.Charset = "iso-8859-1"
%>

Hello

html or the X part ?
cool down

XHTML 1.0 (regardless of whether it’s Strict, Transitional or Frameset) may be served as text/html, provided that you follow all the guidelines in Appendix C of the XHTML 1.0 specification.

If you do, the document is HTML to all intents and purposes. You cannot use any XML-features such as namespaces or CDATA-sections.

That’s a very primitive content negotiation script, which doesn’t take into accound things like quality values (Q values). For instance, your script would serve application/xhtml+xml to a user agent sending this Accept header:

Accept: text/html; application/xhtml+xml;q=0

Not really a good move, eh? :slight_smile:

Correct, I should have said XHTML 1.0 as a hole

Correct again, this is a more advanced one:

<?php
$charset = "iso-8859-1";
$mime = "text/html";
function fix_code($buffer) {
return (preg_replace("!\\s*/>!", ">", $buffer));
}
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
        if(preg_match("/application\\/xhtml\\+xml;q=([01]|0\\.\\d{1,3}|1\\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
        	$xhtml_q = $matches[1];
                if(preg_match("/text\\/html;q=q=([01]|0\\.\\d{1,3}|1\\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
                	$html_q = $matches[1];
                        if((float)$xhtml_q >= (float)$html_q) {
                        $mime = "application/xhtml+xml";
			}
                }
        } else {
           	$mime = "application/xhtml+xml";
                }
}
if($mime == "application/xhtml+xml") {
	$prolog_type = "<?xml version=\\"1.0\\" encoding=\\"$charset\\" ?>\
<!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/1999/xhtml\\" xml:lang=\\"en\\" lang=\\"en\\">\
";
} else {
	ob_start("fix_code");
        $prolog_type = "<!DOCTYPE html PUBLIC \\"-//W3C//DTD HTML 4.01 Transitional//EN\\" \\"http://www.w3.org/TR/html4/loose.dtd\\">\
<html lang=\\"en\\">\
";
}
header("Content-Type: $mime;charset=$charset");
header("Vary: Accept");
print $prolog_type;
?>

Lot’s of Lemmings are jumping off cliffs, do you want to be a Lemming?

http://www.spartanicus.utvinternet.ie/no-xhtml.htm

That is actualy not true. This myth comes from a nature movie made by Disney, which wanted to show the idiocy of lemmings (or whatever) and threw bucketfuls of them over the edge of a cliff.

Therefore, I’ll continue to use XHTML 1.1.

I keep seeing on forums (and here on this thread ) that IE cannot handle xhtml served as content type xhtml+xml.

I’ve been serving websites as the following for months with no problems in IE.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<title></title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
</head>
<body>
</body>
</html>

The example given in the link above is just stupid. They send the document with an .xhtml extension so IE prompts you to download it. I put the same code on one of my servers and have the server parse .xhtml extensions and IE does not have a problem. http://www.easywebdev.com/demo.xhtml That is a webserver issue not a browser one, looks like people think because firefox can render a doc with an .xhtml extension IE can’t handle xhtml at all.

Anyone care to offer up some concrete proof of IE having problems with xhtml? I can’t find any.

Sorry, I may be being thick Easywebdev, but that url you quote is being served as text/html by your server rather than application/xhtml+xml so IE wouldn’t have a problem with it - it thinks it’s “tag soup”. You’d need to get the server to serve the page as application/xhtml+xml to see the issue with IE.

That demo is from the link above my first post. They give it as an example of IE not supporting xhtml but the reason IE prompts for a download from their site and not mine is their server does not parse .xhtml extensions.

I’m going to do a little experimenting with the server side and get it to serve .xhtml as an xhtml+xml mimetype.

Let us know what happens!

Blech, when I serve files with an .xhtml extension as application/xhtml+xml IE spits it’s dummy out and prompts to download the file. Just checked the link to the original and they do serve it as application/xhtml+xml. Heh, I jumped on the .xhtml extension and stuck my foot in my mouth without doing any testing :slight_smile:

I’ll leave the file in place in case anyone wants to experiment with it.

Looks like I’ve been feeding IE tag soup.

  1. Unless your serving up your pages as application/xhtml+xml then this isn’t real xhtml. It’s fake xhtml.

  2. IE is displaying your pages using quirks mode because you used <?xml version=“1.0” encoding=“iso-8859-1”?>. So basically you’ve wasted your time using xhtml and standards because IE is rendering your pages the same way it renders a crappy frontpage website. Remove that line and be happy with valid fake xhtml and then wait until IE can handle true xhtml like the rest of us. :slight_smile:

No. IE cannot handle XHTML as ‘application/xhtml+xml’ regardless of extension, nether does it properly handle HTML 4.01 but that’s another story.

I assume that you mean that you’re specifying application/xhtml+xml in your <meta/> tag. In that case I’m sorry to inform you that it has no effect whatsoever.

The media type (a.k.a. content type, a.k.a. MIME type) must be sent as a proper HTTP header by the server. The user agent needs to know the content type before it receives a single byte of the document.

Yep, I was using the meta tag. I set up apache on my server to send .xhtml files with “AddType application/xhtml+xml .xhtml” and IE has no idea what to do with it. Hopefully support will be in for the mime type in IE7 but I won’t hold my breath.

Look, the lack of support for application/xhtml+xml is irrelevant; application/xml already works fine and is basically the same (it triggers the XML parser in the browser, which is all you need). The key is that IE doens’t support the XHTML namespace. And no, that won’t change for IE7.

IE7 will not support XHTML.

Using application/xml ‘works’, but you will have to make changes to your IE style sheet since the document will be handled as generic XML. You’ll have to declare display:block for all block-level element types, etc. You’ll probably run into serious problems with lists and tables.

Also, I haven’t checked the implications of this method in conjunction with assistive technologies. I assume there may be problems, since all semantics are lost (for IE and anything on top of that).

Getting a headache with this one.

Can someone post a (useable) head section that is asking for The latest (XHTML) from compliant browsers but tuned also to IE6/7 so that it renders OK. I’ve lost it in the cafuffle above. Cheers?

Do screen readers have a problem with any of this stuff or do they just look at the rendered results?

Screen readers don’t care what the page looks like – they just read the text.

Here you go:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title></title>
</head>

Ah, I have added the two below (missing)
<meta http-equiv=“Content-Style-Type” content=“text/css” />
<meta http-equiv=“Content-Script-Type” content=“text/javascript” />

but also have lower down:

<link href=“css/mainStyle2.css” rel=“stylesheet” type=“text/css” media=“screen,projection” />
<script type=“text/javascript” src=“js/functions.js”></script>

should these be repeated?