Talk to a seasoned developer, and he or she will tell you, "Dreamweaver writes ugly code." What they are really saying is, "I prefer to write my own code." There is a grain of truth in this because hand-written code may only require one line, whereas Dreamweaver MX 2004 will do the same thing using four or five lines. Eventually, you are going to write some of your own code, and when you do, you will have to do some debugging.
Debugging is the process of finding and fixing coding errors. This mainly involves checking the code for syntax errors such as spelling mistakes, misplaced or unbalanced brackets, and so on. It also involves following variables to ensure that they have the values they are supposed to have. Though serious debugging should always be in the realm of the team's "coder," there is a rather interesting method of optimizing code in Dreamweaver MX 2004.
Even though Cascading Style Sheets (CSS) reduce the need for optimized HTML, the key word here is "reduce." As we are fond of saying, "Let the software do the work." Follow these steps to have Dreamweaver scoot through your pages and do the optimization for you:
Open a Dreamweaver MX 2004 page. Select Commands, Clean Up HTML to open the Clean Up HTML/XHTML dialog box shown in Figure 19.5.
To delete tags with no code between them, such as <p></p>, select the Remove: Empty Container Tags.
To remove tags that repeat the same code in the same text block, select Remove: Redundant Nested Tags.
To remove any comments not created by Dreamweaver for items such as Library or template items, select Remove: Non-Dreamweaver HTML Comments.
To remove all Dreamweaver-specific code comments, select Remove: Dreamweaver Special Mark Up.
To remove a specific tag or tags and all of the tag's attributes, select Remove: Specific Tags, and enter the tag or tags to be removed into the text input box.
To consolidate <font> tags, select Option: Combine Nested <font> Tags when possible.
If you would like to see a log of the changes, select Option: Show Log on Completion.
The requested actions will be undertaken, and if the Show Log Option is selected, an alert will display any changes made.
Though Dreamweaver leaves you to your own devices when it comes to quotation marks, there is help available with curly braces, square brackets, and parentheses. Here is how to use it:
Open a Dreamweaver MX 2004 page and select View, Code View. Select a curly brace, square bracket or parenthesis.
Select Edit, Balance Braces, as shown in Figure 19.6. Dreamweaver will select all the code between that brace and the closing brace. If there is a problem, Dreamweaver will beep.
This doesn't work if you select a closing brace.