Appendix B: Roundtrip HTML

 

 
Fig. 1  When Dreamweaver automatically rewrites common errors, an HTML Corrections dialog box will display, telling you what errors were fixed.


 

Fig. 2  Here's a close-up of the HTML Corrections dialog box. The tags that were fixed were either redundant, unclosed, or were improperly overlapped.

Tips

  • To have Dreamweaver automatically check your pages for errors and report to you on what it's changed, see Appendix D, Setting HTML Preferences.

  • Why would you want to use an external editor in conjunction with Dreamweaver? One example is correcting characters with a text editor's Find and Replace feature. For instance, some files that were exported from Quark as HTML contain dingbats that are easier to strip out using a text editor. Dreamweaver does not distinguish between these characters, which look like boxes, and regular spaces. You can open the file in an editor like NoteTab or BBEdit while the page is open in the Document window, make your changes, and save the page. When you return to Dreamweaver, a dialog box will appear telling you the page has been modified and asking you if you wish to reload the page (Figure 3).
  • You don't have to use an external editor. Dreamweaver is a fine text editor for most functions. Previous versions of Dreamweaver for Windows came with a copy of Allaire HomeSite, but Macromedia has since bought Allaire and has integrated these features into Dreamweaver. The Macintosh version used to ship with a copy of BBEdit; you may still be able to find BBEdit online somewhere. You can use copies of these editors, or a plain text editor, or anything in between. Once again, Dreamweaver will do just fine for most any Web or text file, including .css files, XML documents, and even .txt files.
  • Use caution when using Microsoft Word to edit Web pages; see Chapter 10 for details on cleaning up Word HTML.


  Fig. 3  I edited my page in NoteTab and saved my changes. When I returned to the open page in Dreamweaver, this dialog box appeared asking me if I wished to load the saved page.

  Fig. 4  With Code Rewriting preferences turned off, as is the default, Dreamweaver will mark up some of your errors with these yellow tags in the Document window, in Design view. Here, I've turned all the rewriting on.


  Fig. 5 In Chapter 4 and Appendix D, you can find out how to change Dreamweaver's Code Rewriting preferences.

 

Dreamweaver contains many features that help ensure two things: that code is clean, and that you get to choose what changes, if any, Dreamweaver is permitted to make to errors that it finds on your pages. Roundtrip HTML, as these features are called, retains the format of HTML coded outside of the Dreamweaver environment.

You can, however, choose to have Dreamweaver check for and correct common, sloppy errors (Figures 1 and 2). Some other WYSIWYG editors make their own corrections to HTML code, but the changes that Dreamweaver makes are always minimal and essential. You can also choose to have Dreamweaver make no changes at all.

You can use Dreamweaver to edit Web documents that have been hand-coded in a text editor, that have been created in another HTML editor, or that have been generated by a database. You can also use Dreamweaver in conjunction with an external editor, so that you can simultaneously work on the code in one environment while using Dreamweaver for automated tasks and Dynamic HTML.  

In Dreamweaver MX and MX 2004, as described in Chapter 4, you must actually turn on Dreamweaver's automatic code-correcting features in order for Dreamweaver to make routine corrections to pages created or edited using other software. You can turn on these automatic cleanup features in the Code Rewriting panel of Dreamweaver's Preferences dialog box (Figure 4). See p. 147-8 in the Dreamweaver MX 2004 Visual QuickStart Guide, or p. 145 in the MX edition.

If you don't modify your Preferences, Dreamweaver will not change your code even if it's totally lousy. Instead, you'll see yellow notations in the Document window Design view letting you know you flubbed up (Figure 5).

Roundtrip HTML Features:

  • Automatic rewriting of some invalid markup (Figures 1 and 2)
  • Automatic linting of pages created externally (that means it checks your HTML's validity)
  • Integration with external editors