Operation Manual

277
USING DREAMWEAVER
Working with page code
Last updated 3/28/2012
Automatic code modification
You can set options that instruct Dreamweaver to automatically clean up your hand-written code according to criteria
that you specify. However, your code is never rewritten unless the code rewriting options are enabled or you perform
an action that changes the code. For example, Dreamweaver does not alter your white space or change the case of
attributes unless you use the Apply Source Formatting command.
A few of these code rewriting options are enabled by default.
The Roundtrip HTML capabilities in Dreamweaver let you move your documents back and forth between a text-based
HTML editor and Dreamweaver with little or no effect on the content and structure of the document’s original HTML
source code. These capabilities include the following:
Use a third-party text editor to edit the current document.
By default, Dreamweaver does not make changes in code created or edited in other HTML editors, even if the code
is invalid, unless you enable code-rewriting options.
Dreamweaver does not change tags it doesn’t recognize—including XML tags—because it has no criteria by which
to judge them. If an unrecognized tag overlaps another tag (for example,
<MyNewTag><em>text</MyNewTag></em>), Dreamweaver marks it as an error but doesn’t rewrite the code.
Optionally, you can set Dreamweaver to highlight invalid code in Code view (in yellow). When you select a
highlighted section, the Property inspector displays information on how to correct the error.
XHTML code
Dreamweaver generates new XHTML code and cleans up existing XHTML code in a way that meets most of the
XHTML requirements. The tools that you need to meet the few XHTML requirements that remain are also provided.
Note: Some of the requirements also are required in various versions of HTML.
The following table describes the XHTML requirements that Dreamweaver meets automatically:
XHTML requirement Actions Dreamweaver performs
There must be a DOCTYPE declaration in the document prior to the
root element, and the declaration must reference one of the three
Document Type Definition (DTD) files for XHTML (strict, transitional,
or frameset).
Adds an XHTML DOCTYPE to an XHTML document:
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
Or, if the XHTML document has a frameset:
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
frameset.dtd">
The root element of the document must be html, and the html
element must designate the XHTML namespace.
Adds the namespace attribute to the html element, as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
A standard document must have the head, title, and body
structural elements. A frameset document must have the
head,
title, and frameset structural elements.
In a standard document, includes the head, title, and body
elements. In a frameset document, includes the
head, title, and
frameset elements.
All elements in the document must nest properly:
<p>This
is a <i>bad example.</p></i> <p>This is
a <i>good example.</i></p>
Generates correctly nested code and, when cleaning up XHTML,
corrects nesting in code that was not generated by Dreamweaver.