JavaScripting Netscape 6: No More Sloppy Code | 2 | WebReference

JavaScripting Netscape 6: No More Sloppy Code | 2

[previous] [next]

Standards ... or be careful what you ask for

Thanks in part to the tireless efforts of Zeldman and Co. ( and to pressure from thousands of developers like you, NS6, IE5.5, and Opera 5 are now the most standards-based, DOM-compliant browsers available. Someday these efforts will pay off for a code-once future (some are already there and challenging others to follow), but for production and educational sites like ours, you need to code for the widest possible audience. That means supporting both legacy and modern browsers.


Browser developers have a problem. They need to support Web pages written for previous generations of browsers that are not standards-compliant while at the same time supporting the newer standards-compliant browsers. How is a modern browser supposed to support pages written for earlier buggy non-conformant browsers while at the same time supporting fully standards-compliant HTML, CSS and JavaScript? On the other hand, how can Web developers write pages that will display as expected on both older and newer browsers?

Older browsers have been very forgiving in terms of dealing with invalid HTML. They've "fixed" your bad markup in ways that you've become used to. Many Web developers have become dependent upon this non-standard fixup performed by the older browsers and don't know how to write valid HTML. The result is what some call "tag soup." Browsers that are standards-compliant depend upon valid markup in order to apply the complex rules of CSS. There is no reliable way for a browser to apply standard layout rules to invalid HTML. You've got to learn to write valid HTML if you're going to support modern browsers. The only other choice is to live in the proprietary world of the 4.x browsers. And that's a Bad Thing (tm).

NS6 relies upon properly nested HTML tags as well as their proper closure.

SGML Document Type Declarations (DOCTYPEs)

The Document Type Declaration or DOCTYPE is an SGML declaration that tells the browser which version of HTML the page is using. Inside the DOCTYPE tag is a Document Type Definition (DTD) that defines what version of HTML you're coding for, and the syntactic rules to follow.


DOCTYPE tags in HTML signify which standard the HTML follows, if any. In the past, DOCTYPEs have not been that meaningful and many Web page authors and authoring tools use DOCTYPEs that do not match the actual HTML. Modern browsers such as NS6 and Internet Explorer 5 for the Mac sniff the DOCTYPE to determine whether an HTML page should be laid out according to the "Quirky" behavior of earlier browsers or if it should be laid out using the stricter modern standards.

It is very important that you use the appropriate DOCTYPE in order to tell the browser how you expect your page to be laid out. Here's a brief DOCTYPE usage guide.

DOCTYPE Mode Example Comment
No DOCTYPE Quirks    
Pre HTML 4.0 DOCTYPEs Quirks <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">  
HTML 4.x Transitional DOCTYPE without a URI Quirks <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
HTML 4.0 Transitional DOCTYPE with a URI Quirks in NS6, Standards in IE5/Mac <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">  
HTML 4.01 Transitional DOCTYPE with a URI Standards <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""> use for documents that validate as HTML 4.01 Transitional that may contain deprecated HTML and that works with the CSS2 box model
HTML 4.x Strict DOCTYPE Standards <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ""> use for documents that validate as HTML 4.01 Strict and that works with the CSS2 box model

For more details on DOCTYPE and other related matters, see Henri Sivonen's fine explanations at Activating the Right Layout Mode in Mozilla and IE5 for Mac and Things to Take into Account When Moving to Standards-Compliant HTML and CSS Authoring.


NS6 supports JavaScript version 1.5 that includes all of the features you're familiar with from JavaScript 1.2 plus some nice additions.

Javascript 1.5 provides support for the ECMA-262, revision 3 Standard ( which adds features such as:

Other enhancements include:

More information can be found at "What is in JavaScript 1.5" at


NS6 supports to a great extent the DOM Level 1 and Level 2 standards. NS6 no longer supports the earlier Netscape Navigator 4.x proprietary DOM that included layers.

[previous] [next]

Created: February 15, 2001
Revised: Mar. 6, 2001