Moving to XHTML 1.1
Wednesday, 24 November 2004
I’ve just finished the move to XHTML 1.1. For the most part it was pretty easy, because when I build this website I build it to validate as XHTML 1.0 Transitional. The difference between 1.1 and 1.0 Transitional are not that big, except for some deprecated tags, such as <strike>
and <u>
and some deprecated attributes such as target
. All in all pretty straightforward.
Of course I noticed that a lot of pages didn’t even validate XHTML 1.0 in the first place, so I had to clean up some earlier weblog entries. D’oh!
One thing keeps bugging me though. The wrap
attribute of the <textarea>
element has also been deprecated, but there is no immediate replacement. I want to turn off wrapping for my lib-scrub demo page, but I haven’t found a way that validates. Any ideas?
Hmm, that lil-scrub is awsome. Cant you do wrapping in CSS?
I’ve tried to use the following CSS: white-space: nowrap;, but it didn’t have any effect in Firefox.
What about this:
overflow: scroll;
I’ve never tried it off with textareas, but it works like a charm on divs and the like.
The
overflow: scroll;
CSS style didn’t work either…Uuuuuuuh …
XHTML 1.1 SHOULD be transmetted as application/xml+xhtml. Otherwise, it is
interpreted as HTML 4.01, and not as XHTML !
But if you try it, you will realise that IE doesn’t support this mime-type.
So, go back to XHTML 1.0, which can have text/html as mime-type !
(if you really want to use 1.1, don’t forget to change the and to use
Header("Content-type: application/xhtml+xml"), otherwise it would be
sent as text/html, as by defaut …)
vchahun: You’re right… XHTML 1.1 should not be send using the text/html
content type. The W3C wrote a note
about this in 2002. However the term SHOULD NOT is used and this is a pretty
important distinction from MUST NOT. The same note refers to RFC 2119 for their definitions.
So, in other words, sending XHTML1.1 as text/html is not strictly forbidden. It
is certainly strongly recommended against, but allowed in particular
circumstances when the
particular behavior is acceptable or even useful. Since IE does not support the
application/xml+xhtml content type I would say that sending as text/html is
certainly useful.
However, I am considering modifying Nucleus CMS and adding content negotiation,
so if the browser accepts application/xml+xhtml it is send as such.
"So, in other words, sending XHTML1.1 as text/html is not strictly forbidden."
I think it has changed.
I’m looking for the link… ;-)
You may use a PHP script to send or not the header.
I use XHTML sctrict, with this in PHP:
<?php
if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")
|| empty($_SERVER["HTTP_ACCEPT"]))
{
header("Content-Type: application/xhtml+xml");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?" . ">\n";
}
?>
Nice site anyway! :-)
You might find this helpful: http://www.workingwith.me.u…
With the method described there you will send your documents as XHTML1.1 with application/xhtml+xml mime-type to compliant browsers (and the w3c validator), and as HTML4.01 Strict with text/html mime-type to legacy browsers. Excellent ;)
When I’m at it, I could as well give some feedback :)
First off, I love this site. The new background with the up side down mountains look great :)
Improvements: I think that the title could be tweaked a bit. The title for this page could be ‘Moving to XHTML 1.1 – rakaz’, instead of just ‘rakaz’. Also, you should set body {padding: 0;} to make it look right in Opera. Another suggestion is to make the navigation position fixed, so I don’t have to scroll up to navigate…
Keep up the good work ;) PS. I don’t know (yet) how to fix the textarea wrap stuff.
zcorpan i agree, need to change the title tags.
: the most important element of a quality Web page" on
http://www.w3.org/QA/Tips/good -titles
see "
if (stristr($_SERVER["HTTP_ACCEPT"], “application/xhtml+xml”)
|| empty($_SERVER["HTTP_ACCEPT"]))
….
stristr() is better than strpos() ?