Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the new recommended standard of HTML & JavaScript?

Of the following:

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 HTML/JavaScript/Ajax it is using and how to change it?

like image 231
RKh Avatar asked Nov 28 '22 04:11

RKh


2 Answers

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

(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.

like image 144
Franci Penov Avatar answered Dec 09 '22 19:12

Franci Penov


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.

like image 36
DoctorLouie Avatar answered Dec 09 '22 20:12

DoctorLouie