17 replies [Last post]
Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 32 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

An attempt to condense and collate some of the views aired on this topical question, to bring some sense to a confusing area.

First draft as such, comments and views and any suggestions as to further clarity and explanations welcome with a view to eventually posting into the 'how to' section.

N.B have attempted to keep it as simple as possible and have purposefully tried not to get sidetracked by deeper issues requiring lengthy explanations that may just start to confuse further, but if any one feels that details may need clarification please say so.


==============================================

HTML to XHTML (Second Draft)

There is a certain amount of confusion around when it comes to the differences and reasons for using one Doctype over another.
This short article will hopefully dispel some of that confusion in as plain a language as is possible, to bring a little clarity to the subject of which standard one should be writing to

In order to understand what were dealing with it is important to understand two issues

  • What is XHTML
  • XHTML is HTML

Firstly we mainly deal in writing web pages using a markup language called HTML which is a subset of the older, more general, and harder to use SGML. This is a language which allows us to markup content in a human readable structure
it is not a programing language nor a scripting one and requires a User Agent (browser) to act as the interpreter of that code for display purposes.


A far more robust and extendable language was required to cater for the ever changing nature of data and which would be able to grow and change with developments yet which would always be backward compatible so that data conveyed by this standard would always make sense
no matter how long ago it was written, this became known as XML (eXtensible Markup language)and it allows for other languages to declared within the same document, which is the extensible part of it's title

XHTML therefore was a method of re-formulating the HTML syntax to be compatible with the far stricter XML syntax whereby tags must be written in lowercase letters, all empty tags must be closed, and elements nested in the correct order in the markup. In other words, the document must be well formed.

This also allows HTML to be part of the extensible nature of XMl and can be seen by the fact that when you declare an XHTML page you should also declare the xml namespace (<html xmlns="http://www.w3.org/1999/xhtml" lang="en">) essentially stating what language this section of the document conforms to , you can also declare further sections to be different languages using further XML namespace declarations

It should be understood that XHTML is a bridge between HTML and XML it is not a new 'Language' but a method of intergratting HTML into XML and is still HTML. Nothing has changed; you are still writing HTML markup.

Declaring your document


It is this area that causes a lot of confusion and debate between two camps, the purists on the one hand and those that wish to follow as closely as possible the latest trends in coding on the other.

At this point to understand the debate surrounding the correct Doctype to use it helps to understand some facts:
  1. A modern user agent(browser) has two possible rendering engines(parsers) that are responsible for the display and rendition of your code, the first is the XML parser and is very strict on the syntax and structure of your code and the second is what is called the 'Tag Soup' parser. The tag soup parser[1] is what is required in order that the majority of web pages on the web written before standards became a strong issue, can and will display it is forgiving of coding errors and will attempt to guess at what was intended when encountering errors or non standard code. If it was not available the majority of the web pages would cease to display .

  2. IE browsers do have a XML parsing engine but they do not understand the MimeType application/xhtml+xml and can only receive and render files delivered as text/html,using the Tag Soup Parser. If a file is sent as application/xhtml+xml it will prompt IE to ask whether you wish to save the file to disk; however IE can render the file once it's saved as HTML.

  3. The reference to tag soup rendering should not be taken to imply that your code is in any way badly written, that is in your hands to write syntax correct well formed code, the tag soup parser does not change the nature of well formed code it will just process it without having to compensate .
  4. The Mime type ( the method of instructing what type of file is being received) is of paramount importance and dictates above all else how the browser should deal with the file; for the purposes of this discussion there are two to consider mime: type text/html and mime type: application/xhtml+xml Most pages written in HTML are delivered as text/html. The correct type for pages written to the XHTML or XML standard is application/xhtml+xml. More on this later.
It is important to declare at the start of the page what type of document you are writing this takes the form of the 'Doctype Declaration'
This has a two fold purpose it's primary aim is to state which set of rules your page is meant to follow e.g HTML 4.01 or XHTML 1.0 along with this you can also declare whether your document follows a 'Strict' implementation or a 'Transitional' implementation of the standards. The DTD tells the validator which rules to apply when validating. You should understand that having valid html does not mean the page will render as you expect (you may have used the markup correctly, but not the right markup). Nor does invalid code mean that it wont render ( the tag soup parser is designed to try and read your mind and correct errors as best as it can). Valid HTML means that you have removed the guesswork from the UA[2] Tag Soup parser, all browsers will understand the markup. Whether they render it as you want is another issue.
So validation is useful in that it will flag up errors in your markup that would cause it to be not well formed even though the browser would be making a good attempt at rendering the code as it considered correct. Pass validation to a strict standard and your assured that your page will meet the requirements of the stricter xml parser and in respect of the Tag soup engine it has no error correction to deal with and can just render your well formed code hapilly.

The second purpose is to switch browsers between the two internal rendering modes these are "Quirks Mode" and "Standards Mode" standards mode most closely follows the W3C guidelines.

Which Doctype to code for

According to the strict letter of the law when you code to XHTML standards the Specs state that you should serve the page up as application/xhtml+xml and that you must use the xml prolog[3] to state the character set in use and which is placed before the Doctype declaration.

This causes the first problem to be dealt with and that is IE which will switch to 'Quirks Mode' if it sees any code/characters before the Doctype Declaration IE is not capable of understanding the application xhtml+xml mime type and will process it as text/html anyway. So we have a quandary. We would like to serve up XHTML correctly but it causes us problems with the most widely used browser.
The W3C recognized this problem and pronounced on the matter that it was acceptable in light of IE switching out of standards mode, that one could serve up XHTML1.0 as text/html without the XML prolog. All well and good we can use and validate XHTML and also ensure that IE complies with the CSS specs as much as possible.[4]


The purists argue against using XHTML for text/html documents
Here is where the confusion arises:

There are a body of people who quite rightly will argue that to serve up XHTML as text/html is just plain wrong and shouldn't be done and that if writing html the only Doctype that should be used is a HTML 4.01 strict type.

This argument is based around a number of very valid points; they would argue that as soon as the mime type text/html is used browsers can only use the tag soup parsing engine and that all benefits of XHTML are lost through that as well as the fact that they would debate that if your not actually availing yourself of the eXtensible nature of XHTML, that is it's ability to cope with mixed language declarations again there is little point to using an XHTML Doctype and often the accusation is leveled that the current trend in using the XHTML declaration is just a fad or trend people like to be seen to be keeping up with the latest technology there is some truth to the opinion as indeed many probably are just using the Doctype for no other reason than to appear to be doing the popular thing without actually understanding whats involved.

The counter argument that many on this forum and elsewhere using XHTML Doctypes would side with is that there are benefits to be gained by writing to the strictest disciplines that are available to us and that in doing so we are ensuring the cleanest , compliant, semantically correct code that is well formed, and that in doing so regardless of whether the browser is using the tag soup parser or it's XML parser we have code that is able to cope with the stricter requirements, if and when our pages are delivered as correct XHTML they would not break and the strict XML parser would be happy in rendering those pages.

It's worth remembering that in essence well formed semantic code will display the same through the tag soup parser as the XML parser, our job is too ensure the code is well written to the guidelines we have chosen.

You will also come across comments that the DTD is pretty much irrelevant as the browser does not actually process the defined document and that in reality all the doctype is good for is switching browsers between the two rendering modes Quirks and Standards, whilst this is essentially correct it takes a rather pedantic view of things; yes the Doctype is mainly needed to switch browsers between quirks and standards, but that is an important issue and is needed and yes maybe the browser doesn't actually reference the DTD url, but the validator does, we state the document definition in order that the validator knows what set of criteria to judge against, we use the reports to manually correct our code satisfying ourselves that we comply with the guidelines, it is irrelevant that the browser does not do this this is the problem of the browser not of our coding as long as we produce compliant semantic code we have done all that we can to adhere to the standards , hopefully one day we will all be able to use XML parsers and see our code display cleanly and correctly without undue modification.

So the point of the purists is noted that html should only be delivered using the HTML 4.01 Doctype. there is nothing wrong in doing this. It is still a valid standard does not mean that you're not keeping up with advancements. There are many of us that prefer to be prepared working to the tightest disciplines that we can. Whilst the W3C says that it is permissable to serve XHTML as text/html then we shall do so, in reality it does no harm contrary to the now infamous article by Ian Hickson 'Sending XHTML as text/html Considered Harmful'

To Conclude

In all of these debates a number of issues stand out as of prime concern above all
other issues. These are:

  • The writing of Semantic well formed standards based markup.
  • Ensuring that your document has a Valid Doctype that switches browsers into Standards mode

It is these factors more than anything that we should all be focusing attention on.
If these principles are followed then you are writing good code, regardless of the Doctype. The purists arguments should not perhaps be taken as literal and the
phrase "Concidered harmful" might be better written as "could be harmful". It is their main
concern that many people sending documents as Doctype XHTML 1.0 but as MimeType text/html
do not understand the issues involved in writting well formed code and that their code will break if served as application/xhtml+xml.

The contra argument could be said to be, worry not so much about the fact that your serving XHTML as text/html
but that it is well formed, semantic code, which will pass the validators scrutiny. The benefits of working
to the tighter discipline that XHTML requires outweigh the fact that your not directly making use of the advanced
capabilities that XHTML offer. Rendering that code using the Tag Soup parser does not mean your code is incorrect
or badly written, the Tag Soup parser presented with clean standards code will quietly process it without having to
guess at it's intended structure.When the time comes that we can make use of pure XML parsers then our code is ready,
conforming to the criteria required.

Choosing that Doctype then.

The first consideration ought to be that with new documents one should use a
strict conforming DTD. There is no good reason to use deprecated tags and attributes.
Doing so will tend to produce a document that is not well formed,and CSS replaces all the deprecated
attributes in markup, and tags such as <b> and <i> have been replaced by the more
meaninful, semantic tags <strong> and <em>. The second concideration must be that you
declare a Doctype and ensure that browsers are switched into Standards Mode where they will most closely conform to the
W3C guidelines

If you are happy that you are writting wellformed, Semantic, standards based markup
then you really have a choice of two Doctypes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd">

If you feel that you would like to adhere to the purists view then use HTML 4.01 it is a perfectly valid
standard to write to and requires very little modification to transpose to an XHTML standard.
If on the other hand like many of us you wish to write to the stricter XHTML disipline then that is fine as long as you ensure
that the code validates to that stricter standard, remember that if you serve up XHTML as text/html the Tag Soup
Parser will not tell you if your code contains errors, it will silently compensate for them. it is up to you
to ensure that you have performed the independant validation to ensure the code is standards compliant.


For those that are interested in attempting to dig deeper into this somewhat contentious area these links are the ones to read:
Footnotes:
  • [1] Prior to December of 1999, there were no really strict standards in place. HTML 2 and 3.2 had made some effort to pull things together. The browser wars mitigated against getting things right, with each vendor trying to outdo the other in features and most importantly and negatively, in fault tolerance.

In the U.S., the Campbell Soup Co. makes a product called "Alphabet Soup". It's a vegetable beef soup with bits of noodles in the shapes of letters. They're all mixed up, making no sense. From this, and the ridiculaous lack of well-formedness in all HTML prior to 2000, and most since, we get the term, tag soup. We really not be so disparaging. It is difficult, and reason for code bloat in browsers, to write fault tolerant code. A more correct term would be fault tolerant HTML parser.

  • [2] Consider this markup:
  • <table height="300">
    Height is not an attribute of the table element. Will the browser try to render a 300px high table, or will it (properly) ignore the height? Now consider this HTML:

    <p>This is <span>badly nested </p>html </span>
    Assuming this CSS;

    p {
    font-size: 1em;
    }

    p span {
    font-size: 1.5em;
    }
    What size will the word “html” be? Your guess is as good as mine.

  • [3] If you're declaring xml1.0 and the utf-8 character set, you need not explicitly make an xml declaration. Any other version or character set does require that it be explicitly declared.
  • [4] N.B This allowance is in respect of XHTML 1.0 ONLY, the second version XHTML 1.1 must not be served as text/html and has to adhere strictly to the proper guidelines of Mime type and prolog which is why this version of XHTML is ruled out for use in this manner

  • Hugo.

    Many thanks to Gary(KK5st) for the footnote text and editorial assistance.

    [/][/][/][/][/]

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    Cyberman
    Cyberman's picture
    Offline
    Regular
    Last seen: 14 years 27 weeks ago
    Joined: 2005-02-11
    Posts: 37
    Points: 0

    Re: RFC: The Eternal Doctype Question

    Great article - I agree wholeheartedly.

    There´s one part I want to comment on:

    Hugo wrote:

    Which Doctype to code for

    Firstly according to the strict letter of the law when you code to XHTML standards the Specs state that you should serve the page up as application/xhtml+xml and that you must use the xml prolog to state the character set in use and which is placed before the Doctype declaration.

    This causes the first problem to be dealt with and that is IE which will switch to 'Quirks Mode' as it trips up if it sees any code/characters before the Doctype declaration


    For the Doctype problem and IE Win, there is a somewhat helpful method:
     
    <!--[if IE]> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <![endif]--> 
     
    <?xml version="1.0" encoding="utf-8"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    


    Apparently (conditional) comments don´t cause Quirks mode - so this way IE gets the Doctype first, while all other browsers ignore the comment.
    Of course, it means that IE get´s the XML declaration after the doctype and a second doctype.

    Since one still had to server text/html for IE, I guess it´ll only be of (limited) use.

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 4 years 32 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    RFC: The Eternal Doctype Question

    That would be the problem IE would still read the second Doctype and I'm not sure of the veracity of having two doctypes ?

    Some people would advocate browser sniffing and serving up text/html or application/xhtml+xml as required but the question would be what if anything is gained by this practise, does the xml parser actually render the wellformed markup any better , not really it's something that would suit perhaps a purists take on things, that browsers that could handle xml parsing would get the correct mime type and those that couldn't would get plain text/html, maybe this is the correct way to approach the situation, but seems a lot of trouble to go to.

    Hugo.

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    Cyberman
    Cyberman's picture
    Offline
    Regular
    Last seen: 14 years 27 weeks ago
    Joined: 2005-02-11
    Posts: 37
    Points: 0

    RFC: The Eternal Doctype Question

    Hugo wrote:
    That would be the problem IE would still read the second Doctype and I'm not sure of the veracity of having two doctypes ?

    According to "javascript:alert(document.compatMode)", IE is in CSS1CompatMode - i.e. Standards.
    It´ll be the same doctype twice, and only IE sees it.

    Frankly, I´d rather serve IE some junk than any other browser. But it doesn´t seem to hurt.

    It´ll validate and send browsers into standards mode - tested with IE, Fx, and Opera.
    (Using the above mentioned document.compatMode .)

    HellsBells
    HellsBells's picture
    Offline
    Leader
    Bedford, UK
    Last seen: 11 years 16 weeks ago
    Bedford, UK
    Joined: 2004-04-07
    Posts: 851
    Points: 0

    RFC: The Eternal Doctype Question

    Great article Hugo - thanks.

    I think many of us on this forum use XHTML 1.0 strict because we see it as the most advanced version of HTML we can safely use without falling foul of the whole IE/XML thing. And we serve it as text/html for the same reason.

    Content Negotiation doesn't seem necessary to me yet. If the code is good - then I don't currently see the point - apart from to make my life more difficult.

    I have been worrying that I've been doing the "wrong thing" but I find it very reassuring that someone of your expertise thinks that this is a sensible approach currently.

    Thanks again
    Smile

    Edit: As Roytheboy pointed out to me a while back - even if you use application/xml the web server will likely serve it up as text/html unless you do some fancy stuff server-side.

    My strategy is so simple an idiot could have devised it!

    "Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

    roytheboy
    roytheboy's picture
    Offline
    Guru
    North Wales, UK
    Last seen: 6 years 4 weeks ago
    North Wales, UK
    Timezone: GMT+1
    Joined: 2004-09-18
    Posts: 2233
    Points: 41

    RFC: The Eternal Doctype Question

    Wow - you have been busy Hugo. Well done old chap =D>

    It's a bit 'deep' for a novice, but then again this is a very complex and misunderstood issue, and to skirt around some of the side-issues will likely attract criticism from the purists.

    The only comment I had was referring to the fact that some people serve xhtml correctly dependant upon the browser but you seem to be about to add something along those lines anyway.

    You might also want to consider adding something about the fact that most server mime headers are pre-set to text/html and that this will override whatever is written in the document's meta tags (although isn't there also a way to locally overrule the server headers at run-time?).

    I know that you know that I know punctuation isn't your favourite subject, so when you're ready to publish, let me know and I'll give it a once-over (no offence intended).

    [edit] HellsBells - you wrote your post while I was writing mine - are you psychic?

    Life's a b*tch and then you die!

    HellsBells
    HellsBells's picture
    Offline
    Leader
    Bedford, UK
    Last seen: 11 years 16 weeks ago
    Bedford, UK
    Joined: 2004-04-07
    Posts: 851
    Points: 0

    RFC: The Eternal Doctype Question

    roytheboy wrote:

    [edit] HellsBells - you wrote your post while I was writing mine - are you psychic?

    I knew you'd say that...

    My strategy is so simple an idiot could have devised it!

    "Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

    Lorraine
    Lorraine's picture
    Offline
    Elder
    UK
    Last seen: 13 years 3 days ago
    UK
    Timezone: GMT+1
    Joined: 2005-01-04
    Posts: 1001
    Points: 0

    RFC: The Eternal Doctype Question

    roytheboy wrote:
    I know that you know that I know punctuation isn't your favourite subject

    Ah but, yeah but, no but ... it is one of his many endearing foibles. Once you get used to it that is then you just read as fast as you can.
    Luv ya Hugo.

    Lorraine
    Lorraine's picture
    Offline
    Elder
    UK
    Last seen: 13 years 3 days ago
    UK
    Timezone: GMT+1
    Joined: 2005-01-04
    Posts: 1001
    Points: 0

    RFC: The Eternal Doctype Question

    Oh and Roy, I still giggle at "marshal" art in the military thread - a relative of Wyatt Earp, perhaps :?: Ducks below the parapet.

    Ciryaquen
    Ciryaquen's picture
    Offline
    Enthusiast
    Last seen: 2 years 37 weeks ago
    Timezone: GMT-8
    Joined: 2005-03-15
    Posts: 74
    Points: 0

    RFC: The Eternal Doctype Question

    Thanks Hugo. It's a nice, plain English summary. It cleared up a few things.

    Hugo wrote:
    IE which will switch to 'Quirks Mode' as it trips up if it sees any code/characters before the Doctype declaration

    Was looking and not finding that with a Google search the other day. How about another section called "how to declare a document type"? Add that as a bulleted point to note, along with the URL to the correct doc types, and maybe a link to the doc type article on A List Apart for further reading.

    Total newbie and purely amateur webmaster...

    roytheboy
    roytheboy's picture
    Offline
    Guru
    North Wales, UK
    Last seen: 6 years 4 weeks ago
    North Wales, UK
    Timezone: GMT+1
    Joined: 2004-09-18
    Posts: 2233
    Points: 41

    RFC: The Eternal Doctype Question

    Lorraine wrote:
    Oh and Roy, I still giggle at "marshal" art in the military thread - a relative of Wyatt Earp, perhaps :?: Ducks below the parapet.

    I can write copy with the best of them, and I understand grammar and punctuation (even if I ignore it all when posting at speed), but at the end of the day I'm a classic dyslexic so I have to work very hard not to spell phonetically. Very hard! Spell checkers are okay until a word can be spelt in more than one way. I also have most of the other classic symptoms such as saying 'left' when I mean 'right' and not being able to remember how old I am, or what my kid's birthdays are, yet being able to remember mathematical formula from 20 years ago. Ho hum - at least logic comes easy to dyslexics Smile

    Life's a b*tch and then you die!

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 4 years 32 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    RFC: The Eternal Doctype Question

    I have to write as quickly as my rabid thought processes work Sad punctuation :oops: lets just pretend I'm writing a legal document for the moment. It was a first draft - he said defensively- I will look at using some of those funny little symbols and at cleaning up some of the grammar before a certain other member has cause to remark :wink:; anyway as Lorraine said you just have to read quickly it's a bit like those times that you stumble and have to run to prevent yourself falling over Smile

    cyberman it's an interesting point, it would naturally validate and as you have shown IE switches to 'Standards' ok and would tend to agree that one shouldn't worry too much what we send IE it can only use it's 'Tag Soup' parser anyway and as long as the markup is well formed we have done our job so to speak; yet I have never seen it as a suggested means of coping with the prolog - application/xhtml+xml issue.

    HellsBells the general opinion seems to be that it isn't worth browser sniffing although there are those that do it as a matter of course. It would require that the server mime type be reset though as the header is supposed to be the overriding factor in such things and by default servers will serve files as text/html I think.

    Lorraine thanks for the kind words makes my heart glad to think I still have my foibles Smile

    Roy I agree it is starting to become deep but that is the trouble with this sort of subject it's actually incredibly difficult to keep within the confines of laymans terms I was having to resist the temptation to start explaining side issues in more depth It could easily have been twice as long; having said that certain areas may well need fleshing out such as the 'content negotiation' issue; but I an nervous about getting to carried away and of loosing the Tyros' edge.

    As for overruling the headers, I know that you can using PHP not sure off hand how else except that I guess you can with JavaScript.

    Ciryaquen Yes I may well think about a basic summary of using a doctype, the piece does not really reach a conclusion as such and could possibly do with a basic instruction, although there are some guides already in the 'How To' section on that subject.

    On the subject of ALA guide on the subject I have become a little less enthusiastic with it as some parts are slightly misleading, not completely accurate and the whole article could do with freshening up really. Sorry ALA.

    I shall review things tomorrow when my little brain has recovered from the drain on it's meagre resources.
    Thanks for the feedback so far.

    Hugo.

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    Lorraine
    Lorraine's picture
    Offline
    Elder
    UK
    Last seen: 13 years 3 days ago
    UK
    Timezone: GMT+1
    Joined: 2005-01-04
    Posts: 1001
    Points: 0

    RFC: The Eternal Doctype Question

    Hugo - I've got a few spare "full stops" if you need them. Wink

    roytheboy
    roytheboy's picture
    Offline
    Guru
    North Wales, UK
    Last seen: 6 years 4 weeks ago
    North Wales, UK
    Timezone: GMT+1
    Joined: 2004-09-18
    Posts: 2233
    Points: 41

    RFC: The Eternal Doctype Question

    Hugo wrote:
    As for overruling the headers, I know that you can using PHP not sure off hand how else except that I guess you can with JavaScript.

    :oops: now I feel really stupid - of course you can set the headers in php; I do it regularly for other purposes. How could I forget that! Must be the heat :oops:, or maybe old age Crying

    header('Content-type: application/xhtml+xml');

    I'm not going to get over this one - I can't even blame it on my dyslexia :oops:

    As for Javascript: I think not, as it is purely client-side. Unless it can re-call the page, intercept and change the headers before reloading (?)

    Life's a b*tch and then you die!

    Cyberman
    Cyberman's picture
    Offline
    Regular
    Last seen: 14 years 27 weeks ago
    Joined: 2005-02-11
    Posts: 37
    Points: 0

    RFC: The Eternal Doctype Question

    Hugo wrote:
    one shouldn't worry too much what we send IE it can only use it's 'Tag Soup' parser anyway and as long as the markup is well formed we have done our job so to speak;

    Indeed, right now, the point is moot. Let´s see what IE7 will be able to do, I wouldn´t be surprised if they implement quirks/standards mode for XHTML as well.
    That code was the result of a thread at MozillaZine.

    gary.turner
    gary.turner's picture
    Offline
    Moderator
    Dallas
    Last seen: 20 hours 8 min ago
    Dallas
    Timezone: GMT-5
    Joined: 2004-06-25
    Posts: 9742
    Points: 3821

    RFC: The Eternal Doctype Question

    To extend on roytheboy, The document's PHP reads the browser request header (in a server global variable) and inspects the accepted MIME types. If application/xhtml+xml is there, it delivers that header content. Else, text/html is delivered. This is not browser sniffing, as any UA that says it can handle it gets it. Were Firefox or Opera, eg., not to include the capability in the request header, they, too, would get text/html.

    cheers,

    gary

    If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 4 years 32 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    RFC: The Eternal Doctype Question

    Interesting link cyberman, thought it took a while for then to grasp your point though. Sadly I guess the one great problem would rest with the fact that if we were intending to serve up XHTML correctly and using conditional comments to insert a Doctype before the prolog for IE ultimately it would be defeated by the fact that IE can not render application/xhtml+xml and would treat it as an xml file.

    :oops: My turn to play dumb, Javascript is of course client side. I would imagine it would have to go through some neat tricks to rewrite something already received .

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 4 years 32 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    RFC: The Eternal Doctype Question

    Your quite correct Gary, I had forgotten completely that the request header states what mime types are accepted and understood making for a very simple and effective way of returning a suitable mime type using PHP.

    Still leaves us with the fact that many consider it pointless to do so, but I reserve judgement on that one.

    Hugo.

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me