|
Posted by Neredbojias on 10/30/02 12:01
Well bust mah britches and call me cheeky, on Mon, 28 Jan 2008 17:56:50
GMT Jeff scribed:
>>> You will find very few pages being served properly as xhtml when you
>>> check them.
>>
>> A web page written and served properly as xhtml can be all html, all
>> xml, or a combination of both. When a page is written in xhtml that
>> includes only code that is part of html, then of course it serves no
>> useful purpose to write it in xhtml instead of html, but it also does
>> no harm if you know xhtml well and are properly set up to serve it.
>> However if the page includes some xml, then you have to use xhtml,
>> unless you can use some tricks to make the xml part show up. PCs are
>> now just a small part of the many computer devices out there. Many of
>> the modern small and portable devices are xml devices.
>
>
> Now that is something I'm interested in.
I recently updated my home page to xhtml where, via php, the same page is
served as application/xhtml+xml to any browser which can handle it and
text/html to IE. It validates and works fine, but there is one or two
things I'm not sure about. Here is the (relevant) code:
<?
if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
header("Content-Type: application/xhtml+xml; charset=UTF-8");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "\r\n";
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
echo "\r\n";
} else {
header("Content-Type: text/html; charset=UTF-8");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo "\r\n";
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>The Neredbojias Website</title>
<meta name="author" content="Neredbojias" />
<link rel="icon" href="nerbo.ico" type="image/x-icon" />
.... (no other meta tags)
</head>
What I don't know is if I need the <?xml version="1.0" encoding="UTF-8"?>
part or not and the disparity between xml version="1.0" and XHTML 1.1.
(xml version="1.1" gives an error.) There's also a question about
needing the plain lang="en" designation. (The xml one _is_ needed.) As
I said, though, the code above works and returns "valid" from the w3c
markup validator. If you wish to see it in action:
http://www.neredbojias.com/
--
Neredbojias
Riches are their own reward.
[Back to original message]
|