Quick Tip: DOCTYPE Switching, New Documents and the Document Menu

Many modern browsers do something called DOCTYPE switching. They have at least two "rendering" modes. One, "quirks" mode, emulates the non-standards compliant behaviour of many earlier browsers. "Standards" mode, on the other hand, renders according to the standards set by the World Wide Web Consortium (W3C). The browser decides which "rendering mode" to choose depending on the DOCTYPE declaration it finds in the page. The default document type used by GoLive 6.0 is a short HTML 4.01 Transitional DTD declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

That's what you get when you create a new document. That's what you get when you choose Doctype > HTML 4 Transitional from the Document window menu.

So what will most modern, DOCTYPE "sniffing" browsers do when it sees that declaration? It will stay in "quirks" mode. It will only switch to standards rendering with an HTML 4/4.01 Transitional DOCTYPE if the URI (Universal Resource Identifier) is included, as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

It is easy enough to switch this for any given document. Adam Pratt explains how over in his tip #9 over at the GoLive in 24 site.

It is also possible to change GoLive's default behaviours in this respect as Adam noted.

Here's how.

Step 1:
In GoLive, choose File > Open and navigate to the Settings/DocumentStore/examples folder underneath the GoLive installation folder. Open the transitional.html document.

Default Transitional HTML Document

Step 2:
While holding down the Alt key, choose Doctype > HTML 4 Transitional from the document window menu. Save and shut the transitional.html example document. First stage complete. Next time you create a new document, you will have the long DOCTYPE.

Choose Transitional Doctype in the Document Window Menu

Step 3:
Now let's tackle the DOCTYPE menu. A little bit more file editing. Navigate to the Settings/MarkupGlue/html folder and open the html.aglmgb settings file.

Open the html.aglmgb Settings File

Step 4:
A couple of changes here, and we're done. Basically, we need to edit the HTML 4.01 Strict, Transitional and HTML 4.01 Frameset entries in the syntax element of this file. Essentially, we need to switch "no" to "yes" for the addurl attribute of these elements, as highlighted here (I did a Rewrite Source Code on the file before editing it, to make it easier to read). Alternatively you can download my edited file and use it as a replacement.

Change No to Yes





Step 5:
Save the changes to html.aglmgb and restart GoLive and that's it. You've changed the default behaviour of the application to write long DOCTYPES. If you choose HTML 4 Transitional or HTML 4 Frameset from the DOCTYPE menu, you will get the long declaration. Holding down the Alt key will now switch to the short declaration.

New Item Button




So why did we only edit the HTML 4.01 Strict, Transitional and Frameset definitions in the markup glue file? Because they are the only ones which will cause a switching browser to use quirks mode if the URL is not added to the DOCTYPE, in theory. With HTML DOCTYPE declarations which precede HTML 4 (HTML 2, HTML 3.2), DOCTYPE switching browsers will stay in quirks mode regardless of whether a long or short declaration is used. Likewise if you use an XHTML DOCTYPE. Andy anyway, GoLive writes the URL by default for XHTML declarations. We did not need to change the HTML 4.0 and HTML 4.0 Frameset definitions in the html.aglmgb file as opposed to the 4.01 definitions because GoLive does not write HTML 4.0 DOCTYPEs from the UI. Choosing an HTML 4 option from the menu uses HTML 4.01 by default.

You can find information on how each of the following browsers use DOCTYPEs for switching at the following URLs:

Mozilla browsers: Mozilla Doctype information
Internet Explorer 6.0 (Windows): IE6 Doctype information
Opera 7: Opera 7 Doctype information

I haven't been able to locate an official document for IE5 Mac or Safari as yet.