views:

423

answers:

14

From all those:

HTML, XHTML, DHTML

which one is the present standard? Which one to use for better browser compatibility?

Similarly, what are the recommendations for JavaScript and Ajax?

Edited:

I design my applications using Aptana Studio. How to know which version of HMTL/JavaScript/Ajax it is using and how to change it?

+1  A: 

I think it is

HTML 4.01.

which is mostly supported by all browsers.

Also Aptana is just a document editor and you have full control over the version specified for you HTML and JavaScript.

Also Ajax is not a technology and I don't think there is an official version number for Ajax. Although Ajax implementation by each vendor may have one.

rahul
Ajax isn't a technology. It's a buzzword for "Using JavaScript to make an HTTP request without leaving the current page" (and that can be done with a bunch of different technologies).
David Dorward
+1  A: 

DHTML isn't a standard as such -- it's just a combination of (X)HTML and JavaScript. The standard with the most momentum behind it is HTML5, as Asaph said. JavaScript itself (properly known as ECMAscript) is also developing fast, with a version 1.6 document being released recently.

Many people suggest using XHTML, but you technically have to violate the standard in order to get it to work across browsers. If you are just looking for current compatibility, then HTML4 is well-supported, and parts of HTML5 are beginning to appear in some browsers. Having said that, I would definitely plan for everyone to use HTML4, and then enhance the site for those with HTML5.

Dave
of course, the HTML5 momentum is still not enough to have it delivered as an official W3C standard before 2012. :-)
Franci Penov
Which is a shame, really!
Dave
It isn't a shame. The spec for HTML5 **really** needs a lot of work.
David Dorward
@David Dorward by that standard the HTML4 spec must be unusable for you. It doesn’t even define error handling! ;-)
Boblet
@Franci Penov - 2012? That's just a candidate recommendation. Proposed recommendation is 2022. http://blogs.techrepublic.com.com/programming-and-development/?p=718
Richard Szalay
+1  A: 

HTML5 is not widely used across all modern browsers yet (a lot of the standards are not yet implemented).

Because of this, I'd say that XHTML 1.1 is recommended for todays use.

Edit: You set the version of your document in the doctype-declaration.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
Mickel
Funnily the `script` element has no `language` attribute in XHTML 1.1.
Gumbo
Oh, thanks for the heads up Gumbo :)
Mickel
XHTML 1.1 doesn't work in Internet Explorer unless the browser has (obscure) plugins or you serve it as text/html (which is a dubious practice given rfc2854).
David Dorward
+1  A: 

If you want the best support in all current browsers, HTML5 probably isn't the way to go yet.

HTML 4.01 is ok, and XHTML 1.1 is good.

YMMV, but I've gotten a lot out of XHTML, myself.

Isaac Hodes
A: 

For better current browser compatibility I would stick to either HTML 4 or XHTML, since HTML 5 is still a draft and current support is experimental.

For JavaScript/Ajax, I would recommend using a good helper library. jQuery is a very good one and one of the most widely used.

Konamiman
A: 

HTML 4.01 is the current HTML standard. You can use XHTML if you want to be more "pure" but HTML should be fine. DHTML is not a replacement for HTML. It is an addition which allows you to manipulate objects from JavaScript and move them around.

Steve Rowe
+2  A: 

DHTML is not a standard, it's just an umbrella term for dynamic controls using a mixture of HTML, JavaScript, CSS, etc. Most sites include something that you could reasonably call "DHTML".

HTML5, while promising and the "next big thing", is definitely not implemented across browsers yet. If you need compatibility with a variety of user agents, that is not the way to go.

For maximum compatibility, HTML4 is sort of the gold standard at this point. XHTML 1.1 is also a good way to go, although it probably has a few more quirks than HTML4 at the moment. It really depends on your needs and preferred style between the two.

phoebus
As "next big things" go, I remember HTML 3. It was a complete failure. By the time HTML 5 is standardized, it may well be obsolete and the advanced functionality taken over by Silverlight, Flash, and maybe JavaFX. So I'm not holding my breath.
Cylon Cat
> the advanced functionality taken over by Silverlight, Flash, and maybe JavaFX---Heh! I hope you are kidding...
sundar
A: 

XHTML 1.0 (Strict or Transitional). And for JavaScript and Ajax use jQuery. It will handle most cross-browser compatibility issues.

cxfx
+14  A: 

For markup, I would suggest HTML 4 or XHTML 1.0/1.1. However, if you want to use XHTML 1.1, you have to deliver it as application/xml, which does not work under Internet Explorer and you can't use some of the most used external tools that inject fragments on your page, like AdSense for example. HTML 5 is not fully supported by any browser, and there's no official standard for it yet, so any support might change in future.

For scripting, use ECMAScript 3. ECMAScript 4 was abandoned, and ECMA Script 5 is not yet supported by most of the implementations our there.

For Ajax, stick with XMLHttpRequest Level 1. Level 2 is still a working draft and I am not sure which browsers have support for it.

Update: I don't know how you can force Aptana to a particular (X)HTML version through its settings, but if you have access to the raw document, you can add the proper DTD (<!DOCTYPE>) for the markup you want and Aptana should obey by it. THe DTDs for HTML 4.0 and XHTML 1.0 are as follow (pick only one):

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

(I am sure that Aptana also has this as a choice somewhere in the dialogs/menus when you create a new document and it will add the proper DTD based on that choice.)

To choose the proper version of ECMAScript, just put your scripts into a non-versioned script tag (<script type="text/javascript"> - see note). This MIME type is associated with JavaScript 1.5/ECMAScript 3.

As for the proper XMLHttpRequest, I would suggest (as others did in their answers) using jQuery or any other JavaScript framework (Dojo, Prototype and so on) to take care of doing the right thing on each browser. Aptana comes with most of these JavaScript frameworks out of the box, so you just have to choose the one you want to use. My personal preference is jQuery.

Note: according to IANA (RFC4329) the text/javascript MIME type on the <script> element is obsolete and should be replaced by application/javascript or application/ecmascript. However, the latter are not supported by Internet Explorer.

Franci Penov
Note that the HTML5 draft flatly and intentionally contradicts RFC4329 and says "text/javascript" *should* be used, on the not unreasonable grounds that that's what everybody uses anyway.
Alohci
@Alohci - yes, one of the few reasonable things in HTML5. :-)
Franci Penov
“HTML 5 is not fully supported by any browser” Umm, while this is true, neither is HTML4
Boblet
@Boblet - your point being? there's quite big difference between level of support for HTML4 and HTML5 across the different browser.
Franci Penov
@Franci Hey, it’s you trying to make the point that HTML5 isn’t supported, which is disingenuous. Actually support of the elements shared between HTML4 and HTML5 in browsers is identical, and that’s 90%+ of them. The new HTML5-only elements with poor IE support are a small subset of HTML5 elements, and *there’s no compulsion to use them*.
Boblet
@Boblet - My personal dislike of HTML5 opinion has nothing to do with the fact that HTML5 is not fully supported by all browsers and the HTML5-specific tags that are supported are not the same between different browsers, and those that are the same, are not always implemented to behave the same way. And before you claim that IE is the only one that does not support HTML5, please, read the Wikipedia comparison and note the Gecko and WebKit difference. And remember that there are older versions of Firefox, Safari and Chrome out there that people still use that don't support HTML5 either.
Franci Penov
@boblet - you can correct me if you believe I am wrong, but please do so with facts, instead of ad hominem attacks.
Franci Penov
+1  A: 

Virtually there didn’t happen much since HTML 4.01 in 1999. The majority of browsers do not support much more hypertext markup features than in HTML 4.01.

XHTML 1.0 is just the XML compatible counterpart to HTML 4.01. XHTML 1.1 is a stricter form of XHTML 1.0 and the development of XHTML 2 has been aborted in favor of HTML 5. That’s currently the most promising development in hypertext markup languages, but it’s still a working draft.

So for HTML the current recommendation is HTML 4.01 and for XHTML it’s XHTML 1.1. But XHTML 1.1 requires to be sent as XML and most browsers do have difficulties with this. So it’s rather XHTML 1.0 that has the lead in the XHTML brance since it’s allowed to also be sent as plain HTML.

Gumbo
+1  A: 

HTML5

The markup is basically HTML4 with a support for a few extra tags. And microformats. [The general rule is that anything which is new to HTML5 is and will be supported by Firefox, Safari/Chrome/Webkit and Opera. IE will continue to improve its support for HTML4 for the foreseeable future, but always with a buggy implementation.]

Use the following doctype:

<!doctype html>
<html>
<head>...

This (HTML5 doctype) is not only short and easy to read for yourself, it is becoming the de facto standard. It is understood and handled correctly by all browsers (except Internet Explorer 6, which translates it to XHTML4 Strict, also a perfectly valid doctype.)

This is the doctype/language used by Google on all of their pages. A comment by Cutts led me to think it may help a teeny bit in SEO.

The W3C validator for HTML 5 is still beta, but it is available: http://validator.w3.org/#validate_by_uri+with_options

DHTML is not a language, it is a reference to a collection of technologies. XHTML5 does exist, and can be used, but the "experts" are pushing against it.

SamGoody
HTML5 is not a standard. It is a draft and subject to change (and lots of changes are happening). It isn't ready to be the default choice.
David Dorward
I wrote "it is becoming the de-facto standard." Pretty clear, I think about it not being a formal standard yet. Basically the only things that will change are things that are not yet covered by any other standard. I have been following the changes pretty closely for about a year, and feel it is safe to use, even if there will be some fringe cases that trampled.
SamGoody
+4  A: 

Plain and simple... HTML 4.01 is your best bet for forward and backward compatibility. Considering the fact that XHTML has it's limited browser compatibilities, there's no reason to code strictly with this markup especially if you can have the same functionality, look and feel using a tried and tested markup such as HTML 4.01. New technologists in the development arena will refute this but this is due to their misunderstanding of HTML 4.01 and its abilities, especially since they have been brought up with the strict use of XHTML.

Always think about forward as well as backward compatibility for at least 2 browser versions into the past. Furthermore, test all your code on Opera, Firefox, MSIE, Safari and Chrome to get the best feel for true cross-browser compatibilities, this will help you determine the best markup for the job at hand. Which will indeed be, HTML 4.01.

drlouie - louierd
Furthermore, DHTML (Dynamic HTML) is simply a mix of HTML 4.01, CSS and Javascript.
drlouie - louierd
+1  A: 

Regarding Doctypes ... what samgoody says. Using HTML 5 gives all of the compatibility of HTML 4.01, with the added benefits that you can implement more forward facing attributes/elements as and when you see fit, and you can use XHTML style closing tags if you like them, (I do). There are literally no drawbacks to adopting an HTML 5 doctype.

beseku
HTML5 has weaker QA tools.
David Dorward
http://validator.nu/ is better than the W3C HTML4/XHTML1 validator in my experience, and assuming you’re not using new elements HTML4 QA tools work just the same for HTML5.
Boblet
A: 

HTML and XHTML are the same language, with slightly different syntaxes.

It really doesn’t matter.

Paul D. Waite