DiJ8, creative development
Log in
  Web Design     Portfolio     Entertainment     Guestbook     Contact     About  
  Games     Jokes     Stories     Clippings     Proverbs     Web School     Links  

Web School

good scripting standards, practices, and guidelines

Guidelines HTML CSS Scripting
DHTML Cross Browser Fun Scripts  

This is a short run down on the "correct" way to write scripted code. It lists common standards, best (relative) practices, and general guidelines.

The World Wide Web Consortium (W3C) is an independent standards setting organisation. W3C was created in October 1994 to lead the World Wide Web to its full potential by developing common protocols that promote its evolution and ensure its inter operability. This is the best site to go to see what the current standards are. Previous protocols and standards are available at the W3C site for reference.


Some aspects of writing Web documents are not standards but are just good practices. Below is a list of the scripting fundamentals.

What is client side scripting? Source: Introduction to scripts

A client-side script is a program that may accompany an HTML document or be embedded directly in it. The program executes on the client's machine when the document loads, or at some other time such as when a link is activated. HTML's support for scripts is independent of the scripting language.

Scripts offer authors a means to extend HTML documents in highly active and interactive ways. For example:

  • Scripts may be evaluated as a document loads to modify the contents of the document dynamically.
  • Scripts may accompany a form to process input as it is entered. Designers may dynamically fill out parts of a form based on the values of other fields. They may also ensure that input data conforms to predetermined ranges of values, that fields are mutually consistent, etc.
  • Scripts may be triggered by events that affect the document, such as loading, unloading, element focus, mouse movement, etc.
  • Scripts may be linked to form controls (e.g., buttons) to produce graphical user interface elements.
Top of Page | Fundamentals

Basics of scripting code

The <SCRIPT> element places a script within a document. This element may appear any number of times in the <HEAD> or <BODY> of an HTML document.

A script is defined in an HTML document using the <SCRIPT> tag. The attributes inside a script tag include SRC, TYPE, LANGUAGE, and DEFER.


This attribute specifies the location of an external script.


This attribute specifies the scripting language of the element's contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript"). Authors must supply a value for this attribute. There is no default value for this attribute.


This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of TYPE.


When set, this boolean attribute provides a hint to the browser that the script is not going to generate any document content (e.g., no "document.write" in javascript) and thus, the browser can continue parsing and rendering.

Top of Page | Fundamentals

Which language to use

As HTML does not rely on a specific scripting language, document authors must explicitly tell browsers the language of each script. This may be done either through a default declaration or a local declaration.

Authors could specify the default scripting language for all scripts in a document by including the following <META> declaration in the <HEAD>:
<META http-equiv="Content-Script-Type" content="type">
where "type" is a content type naming the scripting language. Examples of values include "text/tcl", "text/javascript", "text/vbscript".

Because the scripting language must be set explicitly for each rendering of a script then not only can you have as many <SCRIPT> tags as you desire but they can each be a different language.

The two most common languages used in client side scripting are VBScript and JavaScript. VBScript is a Microsoft proprietry language so is only compatible with Microsoft browsers. If your target audience is only going to use Microsoft Internet Explorer then VBScript is a possible language choice. JavaScript is supported by most browsers, including the two most popular, Microsoft Internet Explorer and Netscape Navigator/Communicator. Because of its wide support this is the usual language of choice for client side scripting.

Top of Page | Fundamentals

Simple guidelines to follow

One very important guideline is the Give descriptive names and ID's for elements and variables section of web development guidelines. Something to take note of is that should an HTML element have both a NAME and an ID then the NAME takes precedence over the ID.

All script elements are evaluated in order as the document is loaded. Should a script dynamically write HTML code then the HTML code is written in the place of the script.

Remember to include the language of the sripting that you are using in your <SCRIPT> tag.

Top of Page | Fundamentals

Working with browsers that do not support scripting

Creating a non-scripted page

If a browser does not support scripting then an alternative must be available. This is done using the <NOSCRIPT> tag. A <NOSCRIPT> tag should be entered in all documents where scripting is a part of the code. Between the opening and closing tags of NOSCRIPT should reside code that will work with older browsers because scripting has been around for a while and if the browser doesn't support scripting it is unlikely to support many features of the likes of HTML 4. A simple redirection is usually the best option here.

Hiding the code from browsers without script support

Browsers that don't recognize the <SCRIPT> element will likely render that element's contents as text. Some scripting engines, including those for languages JavaScript, VBScript, and Tcl allow the script statements to be enclosed in an SGML comment (<!-- -->). Browsers that don't recognize the <SCRIPT> element will thus ignore the comment while smart scripting engines will understand that the script in comments should be executed.

When using the SGML comment to hide script it is necessary to hide the closing comment tag from the script. Different script languages use different comments so it is important to note at least the most common ones.
JavaScript comment = // (slash slash) so closing comment line could look something like
// end hiding contents from old browsers -->
VBScript comment = ' (apostophe) so closing comment line could look something like
' end hiding contents from old browsers -->
TCL comment = # (hash) so closing comment line could look something like
# end hiding contents from old browsers -->

Another solution to the problem is to keep scripts in external documents and refer to them with the src attribute.

Top of Page | Fundamentals

Useful Scripting links

Writing your own code is the best way to learn but it is just as important to get help from those that have already been through it all. The following links are just some of the sites around the web that have invaluable information.

Cross-browser scripting according to dij8
http://www.devguru.com/Technologies/ecmascript/quickref/javascript_intro.html DevGuru JavaScript resource.
http://www.devguru.com/Technologies/vbscript/quickref/vbscript_intro.html DevGuru VBScript resource.
http://www.w3schools.com/js/default.asp JavaScript School.
http://www.w3schools.com/vbscript/default.asp VBScript School.
http://www.echoecho.com/javascript.htm Javascript tutorials.

Top of Page | Fundamentals 
 back to the top
  Home     Development     Portfolio     Entertainment     Guestbook     Contact     About  
  Valid XHTML 1.0! Valid CSS! Unicode Encoded