• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter FOUR. Advanced Page Editing > TIP 84: Validating Your Source Code Synta...

TIP 84: Validating Your Source Code Syntax

You spend precious time creating pages that look good and navigate properly. To that end, it behooves you to make sure your pages are free from errors and that they use valid syntax to ensure that they behave as expected in a Web browser.

Using GoLive's built-in Syntax Checker, you can see whether your pages are compliant with a particular DTD (see Tip 65) or whether your code is well formed (meaning all tag pairs are complete and so on). To use the Syntax Checker, choose Edit > Check Syntax, click the Check Syntax button in the Highlight tab of the View palette, or control-click (right-click on Windows) on a page in the Files tab of the Site window and choose Check Syntax (Figure 84a).

Figure 84a. There's a Check Syntax menu item in the Edit menu, a Check Syntax command in the contextual menu, and a Check Syntax button in the Highlight tab of the View palette as shown here.

Once invoked, a modal dialog will open. In the Comply With portion in the upper left, choose one or more DTDs to check against by enabling the checkbox next to them. Alternatively, you could check for well-formedness only.

The Additionally Allowed portion in the lower left lets GoLive-specific tags and attributes go through the checker without being flagged (Figure 84b). If you intend to strip out the GoLive-specific code while uploading (see Tip 222), then enable these checkboxes.

Figure 84b. Choose the DTD to check against and whether to allow additional elements.

By default, the Warnings and Errors checkboxes in the upper right are enabled. For the best results, leave them on. When you're done making your selections, click OK. The syntax checker proceeds, and a list of results is shown (Figure 84c). If errors or warnings are found, the problems are highlighted on the page.

Figure 84c. After running the Syntax Checker, a results list is shown.

Dispatch the Dialog

Want to use the same settings you used last time you checked syntax? Hold Shift when you click the Check Syntax icon in the Highlight palette to bypass the modal dialog and use your previous settings.

Double-clicking on a warning or error in the results list causes the page to pop forward with the problem area in view, ready for you to fix. Using the Outline Editor is the easiest way to fix errors because it not only highlights the errors on the page but also gives a brief description of the problem. If a required attribute of a tag is missing, the Outline Editor even puts a bullet next to it in the tag's attributes list, making it a snap to fix (Figure 84d).

Figure 84d. The Outline Editor is the best choice for fixing syntax errors.

You can run the Syntax Checker on a single open page, on selected pages in the Site window, or on the entire site if the Site window is in focus with no pages selected.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint