tags:

views:

447

answers:

15

When developing a new web based application which version of html should you aim for?

EDIT:

cool I was just attempting to get a feel from others I tend to use XHTML 1.0 Strict in my own work and Transitional when others are involved in the content creation.

I marked the first XHTML 1.0 Transitional post as the 'correct answer' but believe strongly that all the answers given at that point where equally valid.

+6  A: 

I'd shoot for XHTML Transitional 1.0. There are still a few nuances out there that don't like XHTML strict, and most editors I've seen now will give you the proper nudges to make sure that things are done right.

Dillie-O
Not sure how up-to-date <http://developer.mozilla.org/en/Gecko's_%22Almost_Standards%22_Mode> is, but if that still holds true for Firefox, XHTML 1.0 transitional will put Firefox in Almost Standards mode instead of Full Standards mode.
Shadow2531
A: 

Anything that renders your page is will do so regardless of which popular standard you use. XHTML is stricter and probably "better" but I can't see what advantages you will get with one standard over another.

Teifion
A: 

Personally, I prefer XHTML 1.0 Transitional.

XHTML is XML based, so it allows easier parsing and you can also use the XML Components of most IDEs to programatically query and insert stuff.

Transitional is not as strict as strict, which makes it relatively easy to work with, compared to strict which can often be a PITA. Comparison between Transistional and Strict

1.0 is "more compatible" than 1.1 and 1.1 seems to be still under some sort of development.

Michael Stum
+2  A: 

Dillie-O is right on with his answer of XHTML 1.0 Transitional but I would suggest shooting for XHTML 1.0 Strict and only falling back on Transitional if there's some piece of functionality you absolutely need that Strict is not allowing.

Justin Bennett
A: 

Some days when dealing with this DOCTYPE, strict/transitional quirks-mode crap I can't believe that the world wide web works at all!

Zack Peterson
+21  A: 

HTML 4.01. There is absolutely no reason to use XHTML for anything but experimental or academic problems that you only want to run on the 'obscure' web browsers.

XHTML Transitional is completely pointless even to those browsers, so I'm not sure why anyone would aim for that. It's actually pretty alarming that a number of people would recommend that.

I'd say aiming for HTML 4.01 is the most predictable, but Teifion is right really, "anything that renders your page will do".

in response to Michael Stum:

XHTML is XML based, so it allows easier parsing and you can also use the XML Components of most IDEs to programatically query and insert stuff.

This is certainly not true. A lot of XHTML on the web (if not most) does not conform to XML validity (and it needn't - it's not being sent as XML). Trying to treat this like XML when dealing with it is just going to earn you a lot of headaches. This page on Stack Overflow, for instance, will generate errors with many unforgiving XML tools for having invalid mark-up.

Mike Tomasello
A: 

I aim for XHTML 1.0 Trans. It's better to conform so when bugs are fixed in the browsers you won't suddenly be working against the clock trying to figure out what actually needs changing.

In my opinion 1.1 is borked and 2.0 has been smashed to smithereens: Do I really need/want a header/footer tag?

graham.reeds
+3  A: 

@Mike:

While I agree that validity is not needed to make a page render (after all, we have to keep IE6 compatibility in...), creating valid XHTML that IS compatible AND valid is not a problem. The problems start when people are used to HTML 4 and using the depreciated tags and attributes.

Just because the Web is a pile of crap does not mean that every new page needs to be a pile of crap as well. Most Validation errors on SO are so trivial, it shouldn't take too long to fix, like missing quotes on attributes.

But it may still be kind of pointless, given the fact that the W3C does not have any idea where they want to be going anyway (see HTML 5) and a certain big Browser company that also makes operating systems does not care as well, so a site could as well send out it's doctype as HTML 1337 Sucks and browsers will still try to render it.

Michael Stum
+1  A: 

I'm all for XHTML Strict every time. I strongly believe that HTML should be more like XML. It's not hard to validate it if you know XML and the W3's validator ipoints you on the right track anyway.

XHTML 2.0 is heading toward what the W3 have been aiming for for a long time - the semantic web. The best benefit of XHTML 2.0 for me is that every conformant page on the web will be understandable as content, or an article (for that's what pages are - documents) becuase they all apply to the same standard. You would then be able to construct intepreters (i.e. browsers) that present the content in a completely different manner - there's literally thousands of ideas waiting here.

Ross
+3  A: 

There are some compelling warnings about the usage of XHTML, primarily centering around the fact that the mime-type for such a document should be sent as:

Content-type: application/xhtml+xml

Yet IE 6 and 7 don't support this, and then websites must send it as:

Content-type: text/html

Unfortunately that method is considered harmful.

Some also bemoan the fact that although the intent of XHTML is to make web pages parsable by an XML parser, it has in practice failed due to incorrect usage on existing websites.

I still prefer to write documents in XHTML 1.0 Strict, mostly because of the challenge, and the cleanliness and error-checking that a validator gives. I enjoy the syntax a bit better, because it forces me to be very explicit in when tags end, etc. It's more for me a personal choice than purely technical.

Chris
"I enjoy the syntax a bit better, because it forces me to be very explicit in when tags end, etc." well, most of the time, nothing FORCES you that, and you can always write HTML that is 99% 'xml valid' anyway.
Bobby Jack
+5  A: 

Transitional flavors of XHTML and HTML are deprecated. They were intended only for old user-agents that don't support CSS. See explanation in the DTD.

W3C advises that you should use Strict whenever possible, and these days it's certainly possible.

Transitional version has already been removed in XHTML/1.1 and HTML5.


XHTML/1.0 has exactly the same elements and attributes (semantics) as HTML4. The XHTML/1.0 specification doesn't even specify any elements! For anything else than syntax, it refers to HTLM4.

Additionally, you'll be unable to use any feature of XHTML that is not available in HTML (namespaces, XML DOM) if you send documents as text/html, and unfrortunately that is required for compatibility with IE and other HTML-only browsers.

To sum it up: HTML4 Strict.

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

porneL
+1  A: 

If you want to use XHTML 1.0 in an HTML-compatible way, that's fine. However, do note that the W3C validator and the XHTML DTDs know nothing about mime types and how browsers behave differently (like <map> name/id matching) between them. The DTDs know nothing about how well browsers support certain elements (like <embed> for example) either.

What this means is that the XHTML DTDs and the validator don't reflect reality and trying to conform to them is pointless.

If you want to use XHTML just so you can close certain elements with /> (where html-compatible), just use HTML5 markup (so the browser is in full standards mode). HTML5 allows the use of /> in an HTML-compatible way (the same HTML-compatible way you have to do it when using XHTML 1.0 markup with text/html). Then, just stick to what works (you know better than some DTD) in browsers.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8"/>
        <title></title>
    </head>
    <body>
        <p>Line1<br/>Line2</p>
        <p><img src="" alt="blank"/></p>
        <p><input type="text"/></p>
        <p><embed type="application/x-something" src=""/></p>
    </body>
</html>

Then, use http://validator.nu/ to make sure it's well formed at least.

Shadow2531
A: 

I don't think it actually matters whether you use XHTML or plain HTML. The end goal here is to have low maintenance and quick development through a predictable rendering. You can get this from using xhtml or html, as long as you have validating code. I've even heard arguments that it's best to target quirks mode, because new versions of browsers don't change quirks mode, so maintenance is easy.

In the end, it all becomes tag soup, for good reason, because getting web app developers to write error-free html means asking them to write bug-free code. Validators are no help, because they only validate the initial page view. This is also why I've never seen the point in xhtml served as xml for anything beyond static sites. The level of arrogance a web apps developer would need to have to serve up their web app as xml is staggering.

Joeri Sebrechts
A: 

HTML 4.0 Strict, or ISO HTML.

mattl
Have you ever looked at the specification of ISO HTML? It's more restricted than anything else.
+1  A: 

If you have tools to generate your XHTML like any other XML document, then go with XHTML. But when you just use plain text templates, text concatenation, etc. you are OK with good old HTML 4.01.

Browsers now start to support this 10 year old standard.

Important: Avoid being called a bozo when producing XML