HTML or XHTML?

Published on Wednesday, November 2nd, 2005

In Spanish/En Español
På Svenska/In Swedish

It seems like the eternal question amongst web developers: HTML or XHTML? Wherever I look there seems to be posts in forums raising the question, web developers asking me or other people write blog posts about what they believe is the right way to go. I’m not writing this post to tell you what the ultimate choice is, but rather to inform you about the consequences of what you choose. So, let’s take it from the top:

Strict or Transitional?

Definitely strict. Transitional doctypes are exactly what the name implies: a doctype for a phase of transition, not meant to be used permanently. If you write HTML and choose Transitional, you will get the Quirks Mode rendering, which results in web browsers just trying to mimic old and incorrect behavior; this means that rendering will be very different from web browser to web browser. If you choose XHTML Transitional, you will get the strict (or rather, strictest) mode available in IE (Note: from version 6) but you will trigger the Almost Standards Mode in Mozilla-based web browsers.

However, if you use a strict doctype, you will get full standards correct rendering and the most consistent and forward compatible interpretation of your pages.

What is XHTML?

A XHTML document is a document that has to be well-formed according to the rules of XML. Every tag has be closed and correctly nested, and for tags like img, input, link etc, a quick close slash should be added at the end of the tag, like this: <input type="text" />. If you’re writing code that should be accessible for people with Netscape 4 and some other web browsers, then make sure to have a space before the slash (Note: not to make it look good in Netscape 4, but to make it work at all).

You’re supposed to be able to save a page written in XHTML and use it as XML right away.

Why XHTML?

It totally depends on your needs. Some people believe it to be very easy and consistent to code in its XML fashion, where everything has to be well-formed and every element has to be closed. Some people choose it to extend its functionality with namespaces, to use it in conjunction with MathML and so on. Other people might work with XHTML, not out of their own choice, but because the products they/their company use deliver XHTML.

I’ve heard something about application/xhtml+XML?

Yes, it’s all about what MIME type goes with your code. For HTML, the media type is text/html. According to W3C, the organization behind many recommendations such as HTML, XHTML etc (albeit mostly known as web standards), state in their XHTML Media Types document:

‘application/xhtml+XML’ SHOULD be used for serving XHTML documents to XHTML user agents. Authors who wish to support both XHTML and HTML user agents MAY utilize content negotiation by serving HTML documents as ‘text/html’ and XHTML documents as ‘application/xhtml+XML’. Also note that it is not necessary for XHTML documents served as ‘application/xhtml+XML’ to follow the HTML Compatibility Guidelines.

What this translates to is that web browsers who can handle application/xhtml+XML should get it served that way. However, IE doesn’t support that media type, thus requiring you send the code as text/html to it, basically resulting in you having to deliver the pages with different media types to different web browsers, using something called content negotiation. By now, you probably think it all sounds like too much of a hassle, and choose to go with text/html all over. I mean, after all, the Appendix C. HTML Compatibility Guidelines presents the validity of serving XHTML as text/html.

However, then you read this:

XHTML documents served as ‘text/html’ will not be processed as XML [XML10], e.g. well-formedness errors may not be detected by user agents. Also be aware that HTML rules will be applied for DOM and style sheets…

Which means that web browsers will not render your pages as XHTML, but rather as HTML and fall back on error handling and trying to guess how it was meant to be. Then you’re most likely back at square one, because you probably don’t want it this way.

Also, something else that is utterly important to know is that certain scripting will not work when sent as application/xhtml+XML. For instance, if you use document.write or have ads on your page through an ad content provider using it (such as Google AdSense), it will stop working. If you implement an AJAX application using the innerHTML property on an element, that won’t work either.

What’s Robert’s opinion?

My personal opinion is that the most important thing is that you choose a strict doctype, be it HTML or XHTML. If you want to use XHTML and serve it as text/html, make sure that you don’t intentionally have code that would break when served as application/xhtml+XML. Do not use scripting like the one above mentioned in an XHTML page, and go the extra mile to make sure it is indeed well-formed. Be also very aware that a page that isn’t well-formed sent as application/xhtml+XML will not render at all, but will instead only display an error message to the end user.

Anne used me as a bat for HTML, but I’d rather be seen as a spokesman for making a thought-through decision, no matter which one it is. I sometimes work with HTML in may daily job and sometimes XHTML, depending on a lot of factors.

So, choose what you think suits your needs best, and choose wisely. And make sure it’s a deliberate decision.

 

Related reading

70 comments

  • David HÃ¥säther
    November 2nd, 2005 at 23:24

    I find it funny that it’s almost always said about XHTML that one have to nest elements correctly. As if HTML permitted incorrect nesting.

  • Devon
    November 2nd, 2005 at 23:42

    Great summary of everything, in a refreshingly unbiased manner.

  • Steve Williams
    November 3rd, 2005 at 3:16

    Been thinking I ought to serve my site as XML or rewrite in HTML

    So is there a future for XHTML at all? With ’significant’ members of the web standards movement switching to back to HTML and talking about HTML 5 (plus the draconian XML error handling - euch!) is this the beginning of the end for XHTML, or do you see light at the end of the tunnel?

  • Robert Nyman - author
    November 3rd, 2005 at 9:39

    David,

    Well, Transitional HTML would allow incorrect nesting in that sense that you don’t have to close every tag, you can have start LIs without ending them etc.

    But even if HTML wouldn’t allow any incorrect nesting, it’s definitely more crucial for XHTML, that has to be valid XML.

    Devon,

    Thanks, that’s what I was going for. :-)

    Steve,

    Ooh, that’s a tough one. I would say that I definitely believe in a future, some way or another, where one can have XHTML that is valid XML.

    However, one should really be aware that XHTML 2.0 will not be backwards compatible, so if you choose XHTML all across the line right now, don’t expect it to work forever (or even with upcoming versions of XHTML).

    I’m not advising against using XHTML, but if you do, please be aware of all these factors.

  • Jarvklo
    November 3rd, 2005 at 10:41

    Hmm…

    Seems to me it’s time for some friendly myhtbusting :)

    1) Please don’t fall for the myth that Transitional equals Quirks mode! That’s simply not true since it depends on how you write your doctype declaration!

    Take another look in “Activating the right layout mode using the doctype declaration“… According to Mr. Sivonen - the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> Doctype Declaration gets the same treatment as it’s XHTML 1.0 Transitional “counterpart” <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    And frankly - If you make the test you’ll se that Mr Sivonen is correct :)

    2) Please don’t fall for the myth that HTML allows for incorrect nesting of elements!

    Don’t confuse element nesting with the effects of the “optional” properties declared for some start- and end-tags for common elements in HTML!
    Just because a closing tag is optional doesn’t mean that omitting it make the nesting incorrect!

    And PLEASE don’t write “optional tags” up as something that has to do only with HTML4 Transitional since it actually applies to all three HTML4 doctypes! (yeah that’s right - go check the DTD:s )

    3)
    Don’t confuse the requirements put upon user agents that prohibits them from “choking” on HTML - no matter how incorrectly written - with the markup language HTML itself!

    The fact that XHTML compliant browsers are required to “choke” on all errors, and HTML compliant browsers are required to “handle whatever tag soup is flung their way”, has nothing to do with the languages HTML and XHTML

    Apart from that, I would like to pitch in another reflection on (X)HTML Strict - It’s actually easier to learn for beginners than the Transitional “flavour” since it contains fewer elements ant attributes :)

    Apart from that - I totally agree with Devon :)

    PEACE :)

  • Robert Nyman - author
    November 3rd, 2005 at 11:13

    Jarvklo,

    Thank you for your input. Please let me respond:

    1) That is true, and there’s a myriad of doctypes out there. I was just simplifying, since most Transitional doctypes do trigger Quirks mode. For more reading about what doctype triggers what mode:

    Mozilla’s DOCTYPE sniffing

    CSS Enhancements in Internet Explorer 6

    2) A matter of words. Nesting may be correct, but it’s not well-formed in the sense of XML. Absolutely true that optional tags do apply to all HTML 4 doctypes.

    3) I disagree. Yes, it’s not in the languages themselves that tells the user agents how they should handle the code, but by choosing a language and its corresponding doctype, you will get that result. I don’t think it matters to most web developers if it’s actually XHTML or the MIME type that goes with it that might break rendering in a web browser. What’s important for them to know is that XHTML that isn’t well-formed and sent as application/xhtml/xml will stop rendering and display an error message.

    Another important thing I didn’t mention in the article is that a strict doctype is a step towards moving all your presentational code into CSS, instead of allowing a number of attributes for visual formatting on every tag.

  • Faruk AteÅŸ
    November 3rd, 2005 at 11:52

    Oh I see, now that you no longer care about XHTML, the Case for XHTML is no longer relevant reading for your audience anymore? :P

  • Robert Nyman - author
    November 3rd, 2005 at 12:04

    Faruk,

    Well, I wanted this post to be informant without making a stand; rather getting people to realize that the choice is up to them and that there’s no single solve-all answer to that. :-)

  • Chris
    November 3rd, 2005 at 12:26

    Hi Robert,

    I completely agree with Devon, a great summary.

    Thanks.

    Chris

  • Robert Nyman - author
    November 3rd, 2005 at 12:57

    Chris,

    Thank you!

  • Ciro Feitosa
    November 3rd, 2005 at 13:15

    Good post! I would write something about it, but you come first. Congratulations! ;-)

  • Robert Nyman - author
    November 3rd, 2005 at 14:23

    Ciro,

    Thanks, I’m happy to hear that! :-)

  • Steve Williams
    November 3rd, 2005 at 14:54

    I’m not sure I agree with Faruk’s comment (in his linked article) that using HTML is *against* web standards, unless the W3C are recommending we drop it in favour of XHTML right away? Can’t say I’ve read as much, but I haven’t looked either ;)

    I understand that XHTML2 is not compatible, in the same sense that HTML and XHTML are not. But surely, browsers will support the 1.0/1.1 standard for years to come (well beyond current redesign/realignment timescales)? By which time we’ll all be (re)coding sites in XHTML2 anyway… Unless XHTML as it stands is not adopted en masse, and support is dropped… what then? So maybe Faruk has a point after all!

    Oh, and given the amount of adsense on Roger’s site these days, I can fully understand his decision to quit XHTML ;)
    Is third-party non-compliance the driving factor???

  • Robert Nyman - author
    November 3rd, 2005 at 15:12

    Steve,

    That’s really for Faruk to answer, and maybe on his web site in context.

    …browsers will support the 1.0/1.1 standard for years to come (well beyond current redesign/realignment timescales)?

    Most likely, but it will not be such an easy swap from XHTML 1.0 to XHTML 2.0 as people might think.

    Unless XHTML as it stands is not adopted en masse, and support is dropped… what then?

    Maybe HTML 5? Read more in HTML 5 vs. XHTML 2.

    Oh, and given the amount of adsense on Roger’s site these days, I can fully understand his decision to quit XHTML ;)
    Is third-party non-compliance the driving factor???

    Yes, Roger’s got a fair number of ads, doesn’t he? :-)

    I can only answer for me, and I would say no about third parties being the driving factor. In my case, using AJAX was one of the driving forces for using HTML on this web site. And really, third-party compliance wouldn’t be a problem if they followed web standards, would it?

  • Jarvklo
    November 3rd, 2005 at 18:40

    I was just simplifying, since most Transitional doctypes do trigger Quirks mode.

    Well - The Transitional doctype recommended in the HTML4 specification nowadays is the one that triggers standards mode…

    Which IMHO is sort of important to know if you are about to make an informed descision about wether to “go Transitional” or to “go Strict” in the future regardless of if you choose HTML or XHTML :)

    My point again:
    Transitional is in no way automatically equal to Quirks mode - This is a myth that IMHO needs to be smothered in it’s infancy!

    unless the W3C are recommending we drop it in favour of XHTML right away? Can’t say I’ve read as much, but I haven’t looked either

    Steve - maybe http://w3.org/TR/html/ could be considered to be a subtle a hint in that direction (it delivers the XHTML 1.0 recommendation - not the HTML4 recommendation)

    PEACE :)

  • Anne van Kesteren
    November 3rd, 2005 at 18:47

    Transitional triggers almost standards mode at best, never standards mode. Search for “How browsers work” or so or read Henri Sivonen his post again.

    HTML does not allow incorrect nesting. (What does it mean, actually?) The element nodes that end up in the DOM form a nice tree. Would you convert all element node names to lowercase and put them in the XHTML namespace it would be equivalent to having an XHTML document in the first place, with the exception of the trouble that XHTML brings along.

    HTML 5 also has an XML serialization. For example, the new html:canvas element can be used in the XHTML 1 namespace. So can all the Web Forms 2 extensions. Happy coding!

  • Joshua on Fire » Digging Deeper Into XHTML
    November 3rd, 2005 at 19:46

    [...] erstood or even known about XHTML.  I definitely recommend you spend five minutes reading it. http://www.robertnyman.com/2005/11/02/html-or-XHTML/
    Entry Filed under: Technology, Interweb

    Leave a Comment

    [...]

  • Robert Nyman - author
    November 3rd, 2005 at 20:22

    Jarvklo,

    Peace! :-)

    I do appreciate your concern, but as Anne pointed out and as I wrote in the article, XHTML Transitional only triggers Almost Standards Mode.

    Other flavors of Transitional, be it HTML or XHTML, trigger Almost Standards Mode or Quirks mode. So I agree up to 50%: not every Transitional Doctype triggers Quirks Mode, but it never triggers full standards mode either.

    And, as mentioned above, it’s important to use a strict doctype to get hints to how content and visual representation should be separated.

    For everyone: XHTML: Differences between Strict & Transitional.

    Anne,

    Thank you for your comment.
    Although I’m sure you know what it’s about, I like this quote abot nesting:

    HTML tags should be “nested” in a proper order, meaning that the tag opened most recently is always the next tag to close.

    Taken from Nesting Tags.

    Joshua,

    Thank you for the kind words!

  • Anne van Kesteren
    November 3rd, 2005 at 20:27

    What Jarvklo is referring to I guess is a transitional DTD without referencing the actual DTD. Using only the public identifier. That will trigger quirks mode in most browsers for transitional DOCTYPEs though your document will still validate. (I use that technique in my site for example, only then using a strict identifier which triggers standards mode.)

  • Jarvklo
    November 3rd, 2005 at 22:19

    Anne

    No - Actually what I tried to point out (Don Quixote style :) ) is that the statement

    If you write HTML and choose Transitional, you will get the Quirks Mode rendering, which results in web browsers just trying to mimic old and incorrect behavior; this means that rendering will be very different from web browser to web browser. If you choose XHTML Transitional, you will get the strict (or rather, strictest) mode available in IE (Note: from version 6) but you will trigger the Almost Standards Mode in Mozilla-based web browsers.

    IMHO is an unfortunate oversimplification since documents using the the “HTML 4.01 Transitional doctype with URI” as far as I can tell from theory and practice gets equal treatment compared to its “XHTML 1 Transitional” counterpart (as long as you leave out the XML prolog and serve the document as text/html :) )

    ’nuff said - I hope :)

    PEACE :)

  • Robert Nyman - author
    November 3rd, 2005 at 22:55

    Jarvklo,

    I agree and as I stated in my previous comment, there are cases where it results in Quirks Mode rendering and where it results in Almost Standards Mode rendering.

    Neither of those options are good, if you ask me. Go strict, today! :-)

  • Mark
    November 3rd, 2005 at 23:28

    Two corrections:

    Firefox 1.5 will support innerHTML in documents served as application/xhtml+XML, as long as the result is still well-formed XML. That doesn’t make it a good idea, but it does work. You’ll still need to use content negotiation for IE, and there are still tons of other Javascript and CSS differences between HTML and XML mode.

    Also, you can hack Adsense to use it in application/xhtml+XML documents by moving the Adsense code to a separate (HTML) document and including it into your XHTML document with an object element.

  • Jim
    November 4th, 2005 at 2:36

    I agree completely with your summary. However…

    Warning: nitpicks ahead!

    However, if you use a strict doctype, you will get full standards correct rendering

    If only that were true :). I think what you mean to say is more accurately phrased as something like “If you use a strict doctype, you’ll get browsers to adhere as closely to the specification as they can”.

    Every tag has be closed and correctly nested, and for tags like img, input, link etc, a quick close slash should be added at the end of the tag, like this: <input type=”text” />.

    That should read: “Every non-empty element has to be explicitly closed and correctly nested, and for empty element types like img, input, link etc, a slash should be added just before the end of the tag…”

  • Robert Nyman - author
    November 4th, 2005 at 9:53

    Mark,

    I’m really happy to see you here!

    I didn’t know that about Firefox 1.5 (or, rather forgot about it). But, as you wrote, I don’t think it’s a good idea anyway.

    When it comes to Google AdSense and using object elements, I did that on my previous layout here that was also served as application/xhtml+XML. Good to know for people that want to have XHTML and ads.

    Jim,

    “If you use a strict doctype, you’ll get browsers to adhere as closely to the specification as they can”.

    Absolutely true, no web browser is perfect. :-)

    Every non-empty element has to be explicitly closed and correctly nested, and for empty element types like img, input, link etc, a slash should be added just before the end of the tag…

    Again, true.

    That vas some valid nitpicking! :-)

  • Kimmo. » Laajenna Tulikettua -kilpailu
    November 4th, 2005 at 11:56

    [...]
    Jedisthlm.com: Behind the Nordea market information redesign Robert’s talk: HTML or XHTML? BrainFuel: Javascript Libraries (AJAX For Dummies) Mozilla Kicks Off &#8221 [...]

  • l0b0
    November 4th, 2005 at 17:03

    Having developed in HTML tag soup, tables for layout, and forms on one hand, and valid XHTML 1.1+CSS+WCAG on the other, I have to agree with the conclusion, and here are some lessons learned:
    - It’s easier to make XHTML look good, as long as you keep an eye on those browser bugs and support levels.
    - Marking up semantically really does help. Avoid divitis and classitis!
    - I’d argue that making sure the code is valid is more important than whether you use XHTML or HTML.
    - That is, unless you want to use XSLT to separate content from functionality, which is a very nice idea (do you like closing HTML tags inside PHP?)

  • Robert Nyman - author
    November 4th, 2005 at 19:54

    l0b0,

    I’m glad that you agree!

    The lessons you’ve learned are really valuable, and in my opinion, the most important ones when developing web interfaces.

    And XSLT rocks… :-)

  • Pig Pen » HTML OR XHTML? - its an adventure
    November 5th, 2005 at 5:30

    [...] 3:32 pm Robert Nyman has a good post up called HTML Or XHTML? [...]

  • Carlos
    November 5th, 2005 at 11:11

    You wrote:
    “If you choose XHTML TRANSATIONAL, you will get the strict (or rather, strictest) mode available in IE..”

    Is not ?:
    “If you choose XHTML Strict, you will get the strict (or rather, strictest) mode available in IE..”

    nice article.

    congratulations.

  • Robert Nyman - author
    November 5th, 2005 at 12:32

    Carlos,

    Thanks!

    It actually isn’t a typo. IE only implements two rendering modes: Quirks Mode and Strict Mode (although Strict Mode in IE isn’t really strict, since when in that mode it still doesn’t support very basic CSS 2, amongst other things).

    As mentioned in the example in the article, this is opposed to Mozilla web browsers that suppost three modes: Quirks Mode, Almost Standards Mode and Full Standards Mode.

  • Henrik
    November 5th, 2005 at 14:42

    Hi

    I still don’t get exactly why you use HTML instead of XHTML?
    The same result is achieved by using XHTML 1.0 transitional, which doesn’t have to be served with application/xhtml+XML

    Sending the correct mime type depending on browser can be done by checking the HTTP_ACCEPT header, sent to the server every request.

    Furthermore, as previous posters have pointed out, you can use the object element for google’s advertisements. About the asynchronous javascripting - this part is easily programmed to conform with standards - just return XML from your server-script, and then use the DOM methods to change the document in the viewport.

    Henke

  • Henrik
    November 5th, 2005 at 14:49

    BTW… Tell me if you want a script that changes content within XML nodes, or a link to some code changing the mime-type depending on http_accept.

  • Jim’s Blog » The Question
    November 6th, 2005 at 2:36

    [...]
    The Question
    Posted in writing by Jim Mangan on the November 6th, 2005
    Robert’talk, HTML or XHTML: It seems like the eternal question amongst web [...]

  • Robert Nyman - author
    November 6th, 2005 at 13:47

    Henrik,

    As stated above, for a number of reasons, I really don’t recommend using the Transitional doctype. Those doctypes are mostly around for allowing old things to be valid; attributes and such that are really meant to be deprecated.

    Then, according to the Appendix C. HTML Compatibility Guidelines, XHTML 1.0 Strict is also allowed to be sent as as text/html, so it doesn’t have to be Transitional to be ok.

    All the approaches you mention are valid and they are ways to accomplish it; I’m not saying it’s impossible. But from my point of view, the purpose of XHTML is to be the HTML equivalent of XHTML. Why would I then use things that would break when sent properly as application/xhtml+XML?

    On top of that, I would have to use content negotiation to serve HTML to some web browsers as text/html, and XHTML to some web browsers as application/xhtml/xml; to have object elements for some web browsers and the document.write JavaScript for others.

    I don’t know if you were around then, but for the first five months or so, this web page was doing exactly that. But the three main reasons I switched to HTML were:

    1) To much of a hassle to have different versions, and not very suitable to have different web browser-specific code.
    2) As mentioned above, If I use XHTML, my opinion is that it should work when sent as application/xhtml/xml.
    3 I see no gain whatsoever in using XHTML for this specific web site.

    So, thanks for the offers for script and code, but I’ve been doing that myself for quite some time, so I know how to do it. However, if you have some personal favorite links that you want to share with the other readers here, feel free to post a comment with those links.

  • Robert’s talk » Visitors through the roof!
    November 7th, 2005 at 10:20

    [...]
    Visitors through the roof!
    [...]

  • Anthony Ettinger
    November 7th, 2005 at 17:34

    Hmmm….I was not aware that “transitional” was still ‘quirksmode’ in the browsers.

    I tend to disagree, don’t use any doctype at all and you’ll see “quirksmode”, the botched box-model by IE6.

    I spent 2 days banging my head against a wall, until I discovered I needed a doctype. HTML 4.01 transitional fixed all the bugs and issues I was having. Never heard it as still being quirksmode though until I read this.

  • MÃ¥rten
    November 7th, 2005 at 18:39

    Great article! Really mind-blowing stuff. Going to have think about this.

  • Robert Nyman - author
    November 7th, 2005 at 20:46

    Anthony,

    As mentioned above, different doctypes can trigger different rendering strictness, although never full standards mode. Going for a strict doctype is a way of ensuring the most correct rendering while also helping you focus more on putting the presentational code in CSS (since it doesn’t allow much visual formatting in the HTML/XHTML).

    Also, I’m glad to hear that you’ve stopped banging your head on the wall now… :-)

    MÃ¥rten,

    Thank you!

  • Dudu Figueiredo
    November 10th, 2005 at 1:23

    And Robert’s opinion, is it avaliable either in View -> Page Source (when reading this post) ??

  • Robert Nyman - author
    November 10th, 2005 at 9:18

    Dudu,

    Well, sometimes that’s true and sometimes it isn’t. That’s the point here: there’s no single correct answer, everyone need to choose what’s most suitable for them depending on the factors mentioned in the article.

  • Sri’s Blog » links for 2005-11-03
    November 10th, 2005 at 14:36

    [...] n automate almost everything from disk operations to internet (tags: macro software) Robert’s talk » HTML or XHTML? It seems like the eternal question amongst web developers [...]

  • Henrik
    November 13th, 2005 at 11:38

    Hej Robert

    I can understand your viewpoint - if you don’t need the power of XML, then feel free to use HTML instead. Personally I use application/xhtml+XML because sometimes I need to use MathML, and for the feeling that you’re actually using the latest technology.

    Using the object element - does that necessarily break XML compliance? As far as I know it doesn’t.

    “But from my point of view, the purpose of XHTML is to be the HTML equivalent of XHTML.” - do you mean “…the HTML equivalent of XML”?

    About point number one - web browser specific code - the most basic content negotiation would make you write the correct MIME type of the sent document depending on the http_accept of the client browser, but I don’t see how this translates into browser specific - it’s more on/off if a browser accepts the XML mime type or not…

    About the document.write - no browser specific solution is needed - the DOM tree can be manipulated in IE as well…

    “3) I see no gain whatsoever in using XHTML for this specific web site.” - fair point…

  • Robert Nyman - author
    November 13th, 2005 at 21:17

    Henrik,

    Using the object element - does that necessarily break XML compliance? As far as I know it doesn’t.

    Depends on what you want to use it for. It isn’t supported properly in IE for all its different kinds of usage.

    …it’s more on/off if a browser accepts the XML mime type or not…

    Well, yes, the most basic one. But it’s inevitable that other issues or things you will use show up.

    When it comes to document.write as opposed to manipulating the DOM, of course I’d always go for the DOM approach. But what I’m talking about here is third party content that you can’t control, such as ads from Google, that uses document.write to display the ads.

  • Macropsia | Archivo » ¿HTML o XHTML? | IndieSign
    November 21st, 2005 at 1:34

    [...] s diferencias entre ambos estándares y comenta algunos detalles generales en su artículo HTML or XHTML?; un buen punto de partida para los que estén en la duda. [...]

  • Tableless » Blog Archive » HTML ou XHTML?
    December 12th, 2005 at 1:54

    [...] HTML ou XHTML? Pois é… Eu ia escrever algo, mas o cara chegou primeiro! HTML or XHTML? por Robert Nyman. Ele fala sobre perguntas como: Usar HTML ou XHTML? Usar [...]

  • edu.volpe.ch  •  HTML vs. XHTML
    April 13th, 2006 at 15:53

    [...] geben werden z.B. Leere ElementeLeer Elemente müssen geschlossen werden z.B. Weblinks HTML or XHTML? http://de.wikipedia.org/wiki/Xhtml http://jendryschik.de/wsdev/einfuehrung/x [...]

  • (>_<) Doliaku | el blog » Blog Archive » �HTML o XHTML?
    July 15th, 2006 at 0:53

    [...] sionante para IllUstrator: Scriptographer
    �HTML o XHTML?
    Versión original del artículo por Robert Nyman [...]

  • Joe Dolson Accessible Web Design | On Transitional Doctype Declarations
    September 27th, 2006 at 20:09

    [...] or a long time - and it’s commonly opined that the most important choice is actually between strict and transitional doctypes. Recently, this topic has experienced a bit of a [...]

  • Romuald
    October 11th, 2006 at 1:25

    In Internet there are two languages HTML and sound replace XHTML.
    We ask what is needed use?
    How to be in standard W3C ?
    Here is re-think of it:
    http://www.gajdaw.pl/html/html-czy-XHTML.html
    Me personally I use what I love it is XHTML.

  • Digging Deeper Into XHTML at Joshua Jenkins is a Person, not a Webpage
    October 18th, 2006 at 13:56

    [...] tood or even known about XHTML. I definitely recommend you spend five minutes reading it. The Article
    [...]

  • George
    November 22nd, 2006 at 21:43

    So… what do you need to use if you need to use axaj libraries as prototype and scriptacolous and also use google ads ?
    Can’t quite figure it out ….

  • Robert Nyman - author
    November 22nd, 2006 at 21:54

    George,

    Basically, you can use either. But if serve it with the correct MIME type, application/xhtml+XML, things like innerHTML (except for in Firefox) and document.write won’t work.

    Therefore, to make Google ads work, you need to mkae a workaround. Read more in Why won’t AdSense work with true XHTML?.

  • Frontaal.net » Doctype: welke moet ik kiezen?
    December 2nd, 2006 at 7:47

    [...] gsmogelijkheden. De keuze tussen HTML en XHTML komt dus eigenlijk neer op een persoonlijke voorkeur. Conclusie Van de talloze doctypes die je kunt vinden op interne [...]

  • nur Bahnhof » xhtml oder html?
    December 16th, 2006 at 17:41

    [...] XHTML oder HTML? Filed under: CSS&XHTML, Blackspace — Finkregh @ 8:10 pm http://www.robertnyman.com/2005/11/02/html-or-XHTML/ denn Die Syntax von HTML ist komplizie [...]

  • Stefan Van Reeth
    January 21st, 2007 at 2:27

    @Robert
    Referencing Dutch sites? Robert, where you’re from? Nice summary BTW.

    @all
    Why does an informational page gets turned into some discussion about what’s best? If you like HTML more, that’s the way to go for you. And alike for XHTML.

    Admitted, XHTML has some gotcha’s, but reading all the above points ‘em out nicely. And HTML allowing dodgy tag closing, doesn’t mean you’ve GOT to do that :).

    In the end, it all comes down to what one likes best. But be honest, the differences in page rendering when using HTML is areason on it’s own to go XHTML. If it’s only to not drive yourself crazy when trying to achieve a consistent cross-browser rendering :D.

    Personally, I go for strict mode rendering with XHTML, served as XHTML/text. To make sure pages are well-formed, I use the W3C validator. No content negotiating, clean code, (near) consistent rendering and no old-skool stuff.

    As for XHTML 2.0 and HTML 5: don’t hold your breath guys. Those are in the making for years now and they won’t be used in ages to come. When was XHTML 1.0 released? 1998 or so? And still a minority of websites makes use of it.

  • Robert Nyman - author
    January 22nd, 2007 at 8:54

    Stefan,

    I’m Swedish!

    …the differences in page rendering when using HTML is areason on it’s own to go XHTML.

    To my knowledge, using a strict HTML and XHTML DOCTYPE gives the same result in all web browsers. If you know of any exception, please let me know.

  • ThinkingPHP and beyond » How-to: Use Html 4.01 in CakePHP 1.2
    February 21st, 2007 at 18:24

    [...] ody would prefer the good old HTML over the all-so-hyped XHTML, read a little bit about it here. — Felix Geisendörfer aka the_undefined Related Posts [...]

  • Semantik vs. die Frage nach HTML oder XHTML at trilodge computin blog
    April 21st, 2007 at 21:55

    [...] oder Transitional? Diese Frage stellt sich mir viel eher als das ständige HTML vs. XHTML, wie hier, hier oder auch hier. [...]

  • Sitestone » Blog Archive » Wordt het wat met HTML 5?
    June 9th, 2007 at 11:08

    [...] door sommigen betwijfeld. Misschien doet XHTML alleen maar kwaad? Of maakt het eigenljk niet uit of je HTML of XHTML gebruikt? Een aantal guru’s van het eerste moment heeft inmiddels de switch terug naar HTML 4 [...]

  • Jeric
    September 19th, 2007 at 20:55

    really both (XHTML HTML)are the web base today

  • Nathalie
    December 1st, 2007 at 12:45

    Hiya,

    I’m making a website as part of my Personal Project for MYP (Middle Years Programme) which is part of the IBO.

    I’m having troubles with the compatibility in different web browsers.
    I have Dreamweaver but I’m not sure what to use; my options are…

    HTML 4.01 Transitional
    HTML 4.01 Strict
    XHTML 1.0 Transitional
    XHTML 1.0 Strict
    XHTML 1.1
    XHTML Mobile 1.0

    any ideas to help me please?

  • Robert Nyman - author
    December 2nd, 2007 at 23:28

    Nathalie,

    It depends on that what kind of web site it is for, but I would suggest that you would go with a strict Dotype. Also, I’d strongly recommend you to handcode and not use a WYSIWYG tool for building a web site, to learn the ins and outs of HTML. I’d say it’s essential to learn the basics and at the same time get a 100% control of the code itself.

  • Matt
    May 7th, 2008 at 17:01

    I also still don’t know why you would use HTML as opposed to XHTML, the features are relatively the same.

  • kiran
    May 21st, 2008 at 16:12

    I have a problem migrating ASP.NET1.1 code to ASP.NET2.0.
    i have just copied all the .aspx files to 2.0 and have to remove the in 2.0 other wise it wont support 1.1 code.
    Now the problem is some of the 2.0 controls are not functioning properly as the required DOCTYPE is not present.
    what to do for making my web app compatible to both 1.1 and 2.0 controls

  • kiran
    May 21st, 2008 at 16:13

    I have a problem migrating ASP.NET1.1 code to ASP.NET2.0.
    i have just copied all the .aspx files to 2.0 and have to remove DOCTYPE in 2.0 other wise it wont support 1.1 code.
    Now the problem is some of the 2.0 controls are not functioning properly as the required DOCTYPE is not present.
    what to do for making my web app compatible to both 1.1 and 2.0 controls

  • kiran
    May 25th, 2008 at 11:58

    I dont know weather there is any solution for my problem!

  • Web Hosting Finder
    June 25th, 2008 at 2:30

    I would prefer HTML 4.0 for small websites and XHTML for more adavnced websites, Though there are still a large number of popular websites on the web using HTML 4.0

  • Hosting Provider
    June 25th, 2008 at 2:35

    I think XHTML will strict you to code the website more neat and tidy.

  • DOCTYPE.. (X)HTML, Strict or Transitional? :: Winston{YW}
    August 28th, 2008 at 17:27

    [...] HTML or XHTML [...]

  • web standards developer
    October 23rd, 2008 at 17:05

    Hi Robert, last time i visited here its was the old site. Same interest of web standards and XHTML strict only i guess. I have been practising XHTML strict since i find it so easy to already prepare the site with functionaloty to PHP programmers and it actually saves time and development. The CSS makes everything so easy to globally change and edit funtions and layout issues.

    I love this XHTML technology and i dont believe that HTML5 will be a step up but the XHTML 2 might have even better but more cut tags as i have seen in the examples…

    Time till show if XHTML or HTML will be the flagship in the web development future. As i understand its only some 10% or us front-end developers that actually practice web standards with validation options. I think this is the future and its very important also to make websites for more different platform layouts and browsers…

    Cheerio…

    Michael Persson

Share your thoughts:

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> . If you want to display code examples, please remember to write &lt; for < and &gt; for >.

Comment preview

Top results