Setting
Code Preferences:
Code Rewriting
Dreamweaver
can fix some common errors in your code when you open a file in
the Document window. These errors may have been generated by another editor, by hand-writing the code, or they may exist in old files
you haven't looked at in a while.
To
change Code Rewriting preferences:
- From the Document window menu bar, select Edit > Preferences.
The Preferences dialog box will appear.
- In the Category list at the left, select Code Rewriting. That
panel of the dialog box will become visible (Figure 11).
- By default, Dreamweaver will fix your code without telling you.
If you want to see a dialog box that lists the changes Dreamweaver
makes, check the Warn When Fixing or Removing Tags checkbox (Figure
12).
- Dreamweaver fixes two kinds of errors (Figure 13). The
first is Invalidly Nested and Unclosed tags. The other is Extra
Closing Tags. Unless you have a very good reason, leave these
boxes checked so Dreamweaver can catch and fix the errors.
- You can specify exceptions to this rule by excluding some types
of files, including scripts, automatically generated documents,
database files, and so on (Figure 14). These exceptions
are for certain file extensions. To add a file type, type it in
the list box (no commas separate types). To delete a file type,
select it and press Delete.
- To have Dreamweaver code special characters in URLs or attribute
values, check the appropriate box (see Tips and Figure 15).
- When you're finished, you can click on OK to close the Preferences
dialog box, or you can edit more preferences.
|
Fig. 11
The Code Rewriting panel of Dreamweaver's
Preferences dialog box.
Fig. 12 The
Rewrite Code area of the Code Rewriting preferences.
Improperly
unclosed tags look like this:
<b>bold
text
Dreamweaver
will close the tag for you. (Some tags, such as <img>,
don't need to be closed.)
Improperly
nested tags look like this:
<b><i>bold
italic</b></i>
Dreamweaver
will rearrange them for you:
<b><i>bold
italic</b></i>
Extra
closing tags look like this:
<b>bold
text</b></b>
Dreamweaver
will remove the extra end tag.
Keep
in mind that all these errors may occur over much larger chunks
of text and probably aren't as easily spotted by the naked
eye as these examples.
|
Fig. 13 Errors
that Dreamweaver fixes when it rewrites your code..
Fig. 14 The
Never Rewrite Code area of the Code Rewriting Preferences.
Fig. 15 The
Special Characters area of the Code Rewriting Preferences.
Tips
- When
special characters such as spaces and ampersands appear in URLs,
they may need to be coded using Unix escape sequences (which
translate these characters into numbers preceded by percentage
signs). For example, ampersands are coded as %26
and spaces are coded as %20.
To have Dreamweaver convert these for you when they appear in
links on your pages, make sure the Encode Special Characters
checkbox is checked (Figure 15). To turn these off and
use actual ampersands and the like, uncheck the box.
- Similarly,
special characters such as <
& > " are HTML entities. If you view the
source for this page, you'll see <
instead of <
in the code when I want to use that character on the page. When
these entities appear in a menu or as an attribute value (including
in a URL), you may want them either to be themselves or to be
printed on the page. Check or uncheck the box depending on what
sort of attributes you'll be using these in.
|