Charles Cooke online
Charles Cooke online
KompoZer is capable of creating pages using one of several versions of HTML. The file will use code appropriate to the chosen version and the first line of the file will be the Doctype Declaration which identifies the version. It is fundamental that the code and the this declaration must match.
KompoZer is not designed to convert from one version to another hence there is no logical need to rewrite or modify the Doctype Declaration and any attempt to do so within KompoZer will be thwarted and the original declaration will remain.
In spite of this, authors sometimes do want to change the doctype and declaration and usually resort to using external text editors. While this is often not difficult problems can occur if the editor does not support the character encoding used on the page and conversion using KompoZer is preferable. In spite of appearances this is a simple process the greater difficulty arises in determining if such rewriting is admissible. Of this more later.
After a few preliminary checks to ensure that the change will be valid, or can be edited to be so, simply proceed as follows:
The document may now be saved and will have a changed doctype declaration. Checks may need to be made to ensure that the code matches the declaration and any necessary changes made.
Converting a page from one version of HTML to another is not a trivial matter and may require extensive rework which will rarely be justified but there are a few cases where the work required is less and conversion may be.
When Nvu creates documents using transitional doctype it omits the URL part. The result is that MSIE6 and MSIE7 are triggered into Quirks mode so that files may not render as expected. Changing such files to correct transitional mode is completely safe and will correct rendering errors.
This change is completely safe though normally inadvisable. One case where it might be considered required is if you wish to use the target attribute with a href. This is not allowed with strict doctype but is allowed with transitional. (Since strict doctype is a better approach to design, violating it in this one respect might be considered an acceptable compromise.)
This change is safe *. KompoZer will make the required changes
to the code. Since XHTML offers most designers no benefit many will
prefer to standardise all their designs to strict HTML.)
* Though the change is 'safe' a small amount of rework is sometimes
required.
Those who have files based on earlier versions of HTML or using faulty tools may wish to upgrade them. Though considerable rework may be required converting to Transitional HTML may ease the task.
When converting a web page from one version to another there are three issues to consider
In general any of these conversions is possible but it is a question of how much work needs to be put in. Some conversions would require reworking of the page from the ground up. It also depends on what code has actually been used on a page. With some very simple pages probably any of these conversions could be carried out by simply rewriting the doctype declaration and no difference in rendering or validity would result but that is the exception.
Let's suppose you are using KompoZer and, not being a code expert, you work mainly in wysiwyg mode. Designers working this way sometimes get a long way through a design only to discover that they want to use some feature not possible with the version they are using. For example they may want to use the 'target' attribute with 'href' but are using a strict doctype which precludes this. For those not experts, maybe pretty shaky on CSS who started using a strict doctype they may wish they had used transitional because they need to use 'center' or some other deprecated attribute. An other possibility is that the doctype they are using triggers MSIE into quirks mode to that 'the page looks different in IE and Firefox'.
It is NEVER really safe just to change the doctype declaration unless you know the code is valid for the new doctype or you change it to be so. But there are a few changes that are relatively safe.
The method described will always change the doctype but should be restricted to cases where the code will be changed or remains valid.
The tables show changes which will probably work with few if any problems however be warned I have not made comprehensive tests and you should always check validity and cross-browser operation after any conversion.
Conversions from html to xhtml or vice versa (1,2)
| Original doctype | Target doctype | ||
|---|---|---|---|
| Strict | Transitional | Quirks | |
| (X)HTML Strict | Yes | - | - |
| (X)HTML Transitional | - | Yes | - |
| (X)HTML Quirks | - | - | Yes |
Conversions within the same html or xhtml language (3)
| Original doctype | Target doctype | |
|---|---|---|
| Strict | Transitional | |
| Strict | - | Safe |
| Transitional | Not safe (4) | - |
| Quirks (5) | Doubtful | Safe |
Notes (referring to numbers in tables)
Ref 1 Activating Browser Modes with Doctype by Henri Sivonen