Cleaning Up HTML (and XHTML)

You’ve been reading about what great HTML code Dreamweaver writes, and how, no matter what doctype you pick (XHTML 1 or HTML 4.01, for example), Dreamweaver adds the correct tags in the correct order. But there are exceptions to every rule. In the process of formatting text, deleting elements, and—in general—building a web page, it’s quite possible to end up with less-than-optimal HTML coding. While Dreamweaver usually catches potentially sloppy HTML, you may nonetheless run across instances of empty tags, redundant tags, and nested tags in your Dreamweaver pages.

For example, in the normal course of adding, editing, and deleting content on a page (either by hand or even in Dreamweaver’s Design view), you can occasionally end up with code like this:

<div align="center"> </div>

This empty tag doesn’t serve any purpose, and only adds unnecessary HTML to your page. Remember, the less code your page uses, the faster it loads. Eliminating redundant tags can improve your site’s download speed.

Another possible source of errors is you. When you type HTML in Code view or open pages created by another program, you may introduce errors that you need to clean up later.

Note

The Clean Up HTML command doesn’t fix really bad errors, like missing closing tags, or improperly nested tags. You can have Dreamweaver automatically fix these types of problems when opening a file (see Auto-Fixing Your Code).

Aware of its own limitations (and yours), Dreamweaver provides a command ...

Get Dreamweaver CS5: The Missing Manual now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.