tag—illustrates the concept. By default, browsers come with style sheets that define the font and font size for paragraph text (that is, text that falls between
tags in the HTML code). In Internet Explorer, for example, all body text, including paragraph text, displays in Times New Roman, Medium font by default. As the author of a web page, however, you can create a style sheet that overrides the browser’s default style for paragraph font and font size. For example, you can create the following rule in your style sheet: p { font-family: Arial; font-size: small; }
When a user loads the page, the paragraph font and font size settings set by you as the author override the default paragraph text settings of the browser. Users can make selections to customize the browser display in an optimal way for their own use. In Internet Explorer, for example, the user can select View > Text Size > Largest to expand the page font to a more readable size if they think the font is too small. Ultimately (at least in this case), the user’s selection overrides both the default browser styles for paragraph font size and the paragraph styles created by the author of the web page. Inheritance is another important part of the cascade. Properties for most elements on a web page are inherited—for example, paragraph tags inherit certain properties from body tags, span tags inherit certain properties from paragraph tags, and so on. Thus, if you create the following rule in your style sheet: body { font-family: Arial; font-style: italic; }
All paragraph text on your web page (as well as text that inherits properties from the paragraph tag) will be Arial and italic because the paragraph tag inherits these properties from the body tag. You can, however, become more specific with your rules, and create styles that override the standard formula for inheritence. For example, if you create the following rules in your style sheet: body { font-family: Arial; font-style: italic; } p { font-family: Courier; font-style: normal; }
Last updated 3/28/2012
119
USING DREAMWEAVER Creating pages with CSS
All body text will be Arial and italic except paragraph (and its inherited) text, which will display as Courier normal (non-italic). Technically, the paragraph tag first inherits the properties that are set for the body tag, but then ignores those properties because it has properties of its own defined. In other words, while page elements generally inherit properties from above, the direct application of a property to a tag always causes an override of the standard formula for inheritance. The combination of all of the factors discussed above, plus other factors like CSS specificity (a system that gives different weight to particular kinds of CSS rules), and the order of CSS rules, ultimately create a complex cascade where items with higher priorities override properties that have lower priorities. For more information on the rules governing the cascade, inheritance, and specificity, visit www.w3.org/TR/CSS2/cascade.html.
About text formatting and CSS By default, Dreamweaver uses Cascading Style Sheets (CSS) to format text. The styles that you apply to text using the Property inspector or menu commands create CSS rules that are embedded in the head of the current document. You can also use the CSS Styles panel to create and edit CSS rules and properties. The CSS Styles panel is a much more robust editor than the Property inspector, and displays all CSS rules defined for the current document, whether those rules are embedded in the head of the document or in an external style sheet. Adobe recommends that you use the CSS Styles panel (rather than the Property inspector) as the primary tool for creating and editing your CSS. As a result, your code will be cleaner and easier to maintain. In addition to styles and style sheets you create, you can use style sheets that come with Dreamweaver to apply styles to your documents. For a tutorial about formatting text with CSS, see www.adobe.com/go/vid0153.
More Help topics “The CSS Styles panel” on page 120 “Create a new CSS rule” on page 126 Formatting text with CSS tutorial
About Shorthand CSS properties The CSS specification allows for the creation of styles using an abbreviated syntax known as shorthand CSS. Shorthand CSS lets you specify the values of several properties using a single declaration. For example, the font property lets you set font-style, font-variant, font-weight, font-size, line-height, and font-family properties on a single line. A key issue to note when using shorthand CSS, is that values omitted from a shorthand CSS property are assigned their default value. This may cause pages to be incorrectly displayed when two or more CSS rules are assigned to the same tag. For example, the h1 rule shown below uses longhand CSS syntax. Note that the font-variant, font-stretch, fontsize-adjust, and font-style properties have been assigned their default values.
Last updated 3/28/2012
120
USING DREAMWEAVER Creating pages with CSS
h1 { font-weight: bold; font-size: 16pt; line-height: 18pt; font-family: Arial; font-variant: normal; font-style: normal; font-stretch: normal; font-size-adjust: none }
Rewritten as a single, shorthand property, the same rule might appear as follows: h1 { font: bold 16pt/18pt Arial }
When written using shorthand notation, omitted values are automatically assigned their default values. Thus, the previous shorthand example omits the font-variant, font-style, font-stretch, and font-size-adjust tags. If you have styles defined in more than one location (for example, both embedded in an HTML page and imported from an external style sheet) using both the short and long forms of CSS syntax, be aware that omitted properties in a shorthand rule may override (or cascade) properties that are explicitly set in another rule. For this reason, Dreamweaver uses the long form of CSS notation by default. This prevents possible problems caused by a shorthand rule overriding a longhand rule. If you open a web page that was coded with shorthand CSS notation in Dreamweaver, be aware that Dreamweaver will create any new CSS rules using the longhand form. You can specify how Dreamweaver creates and edits CSS rules by changing the CSS editing preferences in the CSS Styles category of the Preferences dialog box (Edit > Preferences in Windows; Dreamweaver > Preferences on the Macintosh). Note: The CSS Styles panel creates rules using only longhand notation. If you create a page or CSS style sheet using the CSS Styles panel, be aware that hand coding shorthand CSS rules may result in the shorthand properties overriding those created in longhand form. For this reason, use longhand CSS notation to create your styles.
The CSS Styles panel The CSS Styles panel lets you track the CSS rules and properties affecting a currently selected page element (Current mode), or all of the rules and properties that are available to the document (All mode). A toggle button at the top of panel lets you switch between the two modes. The CSS Styles panel also lets you modify CSS properties in both All and Current mode.
Last updated 3/28/2012
121
USING DREAMWEAVER Creating pages with CSS
The CSS Styles panel in Current mode In Current mode, the CSS Styles panel displays three panes: a Summary for Selection pane that displays the CSS properties for the current selection in the document, a Rules pane that displays the location of selected properties (or a cascade of rules for the selected tag, depending on your selection), and a Properties pane that lets you edit CSS properties for the rule applied to the selection.
You can resize any of the panes by dragging the borders between the panes, and can resize columns by dragging dividers. The Summary for Selection pane displays a summary of CSS properties and their values for the item currently selected in the active document. The summary shows the properties for all rules that directly apply to the selection. Only set properties are shown. For example, the following rules create a class style and a tag (in this case paragraph) style: .foo{ color: green; font-family: 'Arial'; } p{ font-family: 'serif'; font-size: 12px; }
When you select paragraph text with a class style of .foo in the Document window, the Summary for Selection pane displays the relevant properties for both rules, because both rules apply to the selection. In this case, the Summary for Selection pane would list the following properties: font-size: 12px font-family: 'Arial' color: green
Last updated 3/28/2012
122
USING DREAMWEAVER Creating pages with CSS
The Summary for Selection pane arranges properties in increasing order of specificity. In the above example, the tag style defines the font size and the class style defines the font family and the color. (The font family defined by the class style overrides the font family defined by the tag style because class selectors have higher specificity than tag selectors. For more information on CSS specificity, see www.w3.org/TR/CSS2/cascade.html.) The Rules pane displays two different views—About view or Rules view—depending on your selection. In About view (the default view), the pane displays the name of the rule that defines the selected CSS property, and the name of the file containing the rule. In Rules view, the pane displays a cascade, or hierarchy, of all rules that apply directly or indirectly to the current selection. (The tag to which the rule directly applies appears in the right column.) You can toggle between the two views by clicking the Show Information and Show Cascade buttons in the upper-right corner of the Rules pane. When you select a property in the Summary for Selection pane, all of the properties for the defining rule appear in the Properties pane. (The defining rule is also selected in the Rules pane, if Rules view is selected.) For example, if you have a rule called .maintext that defines a font family, font size, and color, then selecting any of those properties in the Summary for Selection pane will display all of the properties defined by the .maintext rule in the Properties pane, as well as the selected .maintext rule in the Rules pane. (Additionally, selecting any rule in the Rules pane displays that rule’s properties in the Properties pane.) You can then use the Properties pane to quickly modify your CSS, whether it is embedded in the current document or linked by means of an attached style sheet. By default, the Properties pane shows only those properties that have already been set, and arranges them in alphabetical order. You can choose to display the Properties pane in two other views. Category view displays properties grouped into categories, such as Font, Background, Block, Border, and so on, with set properties at the top of each category, displayed in blue text. List view displays an alphabetical list of all available properties, and likewise sorts set properties to the top, displaying them in blue text. To switch between views, click the Show Category View, Show List View, or Show Only Set Properties button, located at the lower-left corner of the Properties pane. In all views, set properties are displayed in blue; properties irrelevant to a selection are displayed with a red strikethrough line. Holding the mouse over a rule that is irrelevant displays a message explaining why the property is irrelevant. Typically a property is irrelevant because it’s overridden or not an inherited property. Any changes you make in the Properties pane are applied immediately, letting you preview your work as you go.
More Help topics “Open the CSS Styles panel” on page 124
Last updated 3/28/2012
123
USING DREAMWEAVER Creating pages with CSS
The CSS Styles panel in All mode In All mode, the CSS Styles panel displays two panes: an All Rules pane (on top), and a Properties pane (on bottom). The All Rules pane displays a list of rules defined in the current document as well as all rules defined in style sheets attached to the current document. The Properties pane lets you edit CSS properties for any selected rule in the All Rules pane.
You can resize either pane by dragging the border between the panes, and can resize the Properties columns by dragging their divider. When you select a rule in the All Rules pane, all of the properties that are defined in that rule appear in the Properties pane. You can then use the Properties pane to quickly modify your CSS, whether it is embedded in the current document or linked in an attached style sheet. By default, the Properties pane shows only those properties that have been previously set, and arranges them in alphabetical order. You can choose to display properties in two other views. Category view displays properties grouped into categories, such as Font, Background, Block, Border, and so on, with set properties at the top of each category. List view displays an alphabetical list of all available properties, and likewise sorts set properties to the top. To switch between views, click the Show Category View, Show List View, or Show Only Set Properties button, located at the lower-left corner of the Properties pane. In all views, set properties are displayed in blue. Any changes you make in the Properties pane are applied immediately, letting you preview your work as you go.
More Help topics “Open the CSS Styles panel” on page 124
CSS Styles panel buttons and views In both All and Current modes, the CSS Styles panel contains three buttons that let you alter the view in the Properties pane (the bottom pane):
Last updated 3/28/2012
124
USING DREAMWEAVER Creating pages with CSS
A
B
C
A. Category View B. List View C. Set Properties View
Category View Divides the Dreamweaver-supported CSS properties into eight categories: font, background, block,
border, box, list, positioning, and extensions. Each category’s properties are contained in a list that you expand or collapse by clicking the Plus (+) button next to the category name. Set properties appear (in blue) at the top of the list. List View Displays all of the Dreamweaver-supported CSS properties in alphabetical order. Set properties appear (in blue) at the top of the list. Set Properties View Displays only those properties that have been set. Set Properties view is the default view.
In both All and Current modes, the CSS Styles panel also contains the following buttons:
A
B
C
D
E
A. Attach Style Sheet B. New CSS Rule C. Edit Style D. Disable/enable CSS property E. Delete CSS rule
Attach Style Sheet Opens the Link External Style Sheet dialog box. Select an external style sheet to link to or import into your current document. New CSS Rule Opens a dialog box in which you can select the type of style you’re creating—for example, to create a class style, redefine an HTML tag, or to define a CSS selector. Edit Style Opens a dialog box in which you can edit the styles in the current document or in an external style sheet. Delete CSS Rule Removes the selected rule or property from the CSS Styles panel, and removes the formatting from
any element to which it was applied. (It does not, however, remove class or ID properties referenced by that style). The Delete CSS Rule button can also detach (or “unlink”) an attached CSS style sheet. Right-click (Windows) or Control-click (Macintosh) the CSS Styles panel to open a context menu of options for working with CSS style sheet commands.
Open the CSS Styles panel You use the CSS Styles panel to view, create, edit, and remove CSS styles, as well as to attach external style sheets to documents. ❖ Do one of the following:
• Select Window > CSS Styles. • Press Shift+F11. • Click the CSS button in the Property inspector.
Enhancements to CSS3 support in the CSS styles panel (CS5.5) A pop-up panel has been introduced in the CSS panel for the following properties:
• text-shadow
Last updated 3/28/2012
125
USING DREAMWEAVER Creating pages with CSS
• box-shadow • border-radius • border-image The options in the pop-up panel ensure that you apply the property correctly even if you are unfamiliar with their W3C syntax.
The pop-up panel displaying options for the CSS3 property border-image
Apply CSS3 properties using the pop-up panel ❖ Click the “+” icon corresponding to these properties. Use the options in the pop-up panel to apply the property.
Specifying multiple value-sets CSS3 properties like text-shadow support multiple value sets. For example: text-shadow: 3px 3px #000, -3px 3px #0f0;
When you specify multiple value-sets in the code view and open the pop-up panel for editing, only the first value-set is displayed. If you edit this value-set in the pop-up panel, only the first value-set in the code is affected. The other value-sets are unaffected, and applied as specified in the code.
Locate properties in the Category view In the category view, text-shadow is listed under the Font category. box-shadow, border-radius, and borderimage are listed under the Border category.
Ensuring compliance with browsers Dreamweaver CS5.5 also supports browser (webkit, Mozilla) specific implementation of box-shadow, border-radius, and border-image properties. In the Category view, use the options under the respective browser category to ensure browser compliance for these properties. For example, to comply with Mozilla’s implementation of the border-image property, edit -moz-borderimage in the Mozilla category.
Preview changes in Live view Changes made to CSS properties are not displayed in the Design view. Switch to Live view to preview changes. You can also make quick edits to CSS3 properties in the Live view, and the changes are immediately reflected in this view.
Last updated 3/28/2012
126
USING DREAMWEAVER Creating pages with CSS
The following CSS3 properties are supported in Live View:
• text-shadow • border-radius • -webkit-box-shadow • -webkit-border-image
Set CSS Styles preferences CSS style preferences control how Dreamweaver writes the code that defines CSS styles. CSS styles can be written in a shorthand form that some people find easier to work with. Some older versions of browsers, however, do not correctly interpret the shorthand. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh) and from the Category list select
CSS Styles. 2 Set the CSS style options you want to apply: When Creating CSS Rules Use Shorthand For Lets you select which CSS style properties Dreamweaver writes
in shorthand. When Editing CSS Rules Use Shorthand Controls whether Dreamweaver rewrites existing styles in shorthand.
Select If Original Used Shorthand to leave all styles as they are. Select According to Settings Above to rewrite styles in shorthand for the properties selected in Use Shorthand For. When Double-Clicking In CSS Panel Lets you select a tool for editing CSS rules.
3 Click OK.
Create a new CSS rule You can create a CSS rule to automate the formatting of HTML tags or a range of text identified by class or ID attributes. 1 Place the insertion point in the document, and then do one of the following to open the New CSS Rule dialog box:
• Select Format > CSS Styles > New. • In the CSS Styles panel (Window > CSS Styles), click the New CSS Rule (+) button located in the lower-right side of the panel.
• Select text in the Document window, select New CSS Rule from the Targeted Rule pop-up menu in the CSS Property inspector (Window > Properties); then click the Edit Rule button or select an option from the Property inspector (for example, click the Bold button), to initiate a new rule. 2 In the New CSS Rule dialog box, specify the selector type for the CSS rule you want to create:
• To create a custom style that can be applied as a class attribute to any HTML element, select the Class option from the Selector Type pop-up menu and then enter a name for the style in the Selector Name text box. Note: Class names must begin with a period and can contain any combination of letters and numbers (for example, .myhead1). If you don’t enter a beginning period, Dreamweaver automatically enters it for you.
Last updated 3/28/2012
127
USING DREAMWEAVER Creating pages with CSS
• To define the formatting for a tag that contains a specific ID attribute, select the ID option from the Selector Type pop-up menu and then enter the unique ID (for example, containerDIV) in the Selector Name text box. Note: IDs must begin with a pound (#) sign and can contain any combination of letters and numbers (for example, #myID1). If you don’t enter a beginning pound sign, Dreamweaver automatically enters it for you.
• To redefine the default formatting of a specific HTML tag, select the Tag option from the Selector Type pop-up menu; then enter an HTML tag in the Selector Name text box or select one from the pop-up menu.
• To define a compound rule that affects two or more tags, classes, or IDs simultaneously, select the Compound option and enter the selectors for your compound rule. For example if you enter div p, all p elements within div tags will be affected by the rule. A description text area explains exactly which elements the rule will affect as you add or delete selectors. 3 Select the location in which you want to define the rule, and then click OK:
• To place the rule in a style sheet that is already attached to the document, select the style sheet. • To create an external style sheet, select New Style Sheet File. • To embed the style in the current document, select This Document Only. 4 In the CSS Rule Definition dialog box, select the style options you want to set for the new CSS rule. For more
information, see the next section. 5 When you are finished setting style properties, click OK.
Note: Clicking OK without setting style options results in a new, empty rule.
Set CSS properties You can define properties for CSS rules such as text font, background image and color, spacing and layout properties, and the appearance of list elements. First create a new rule, then set any of the following properties.
Define CSS type properties You use the Type category in the CSS Rule Definition dialog box to define basic font and type settings for a CSS style. 1 Open the CSS Styles panel (Shift + F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Type, and then set the style properties.
Leave any of the following properties empty if they are not important to the style: Font-family Sets the font family (or series of families) for the style. Browsers display text in the first font in the series
that is installed on the user’s system. For compatibility with Internet Explorer 3.0, list a Windows font first. The font attribute is supported by both browsers. Font-size Defines the size of the text. You can choose a specific size by selecting the number and the unit of
measurement, or you can choose a relative size. Pixels work well to prevent browsers from distorting your text. The size attribute is supported by both browsers. Font-style Specifies Normal, Italic, or Oblique as the font style. The default setting is Normal. The style attribute is
supported by both browsers.
Last updated 3/28/2012
128
USING DREAMWEAVER Creating pages with CSS
Line-height Sets the height of the line on which the text is placed. This setting is traditionally called leading. Select
Normal to have the line height for the font size calculated automatically, or enter an exact value and select a unit of measurement.The line height attribute is supported by both browsers. Text-decoration Adds an underline, overline, or line-through to the text, or makes the text blink. The default setting for regular text is None. The default setting for links is Underline. When you set the link setting to none, you can remove the underline from links by defining a special class.The decoration attribute is supported by both browsers. Font-weight Applies a specific or relative amount of boldface to the font. Normal is equivalent to 400; Bold is
equivalent to 700. The weight attribute is supported by both browsers. Font-variant Sets the small caps variant on text. Dreamweaver does not display this attribute in the Document
window. The variant attribute is supported by Internet Explorer but not Navigator. Text-transform Capitalizes the first letter of each word in the selection or sets the text to all uppercase or lowercase. The case attribute is supported by both browsers. Color Sets the text color. The color attribute is supported by both browsers.
4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style background properties Use the Background category of the CSS Rule Definition dialog box to define background settings for a CSS style. You can apply background properties to any element in a web page. For example, create a style which adds a background color or background image to any page element, for example behind text, a table, the page, and so on. You can also set the positioning of a background image. 1 Open the CSS Styles panel (Shift+F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Background, then set the style properties.
Leave any of the following properties empty if they are not important to the style: Background Color Sets the background color for the element. The background color attribute is supported by both
browsers. Background Image Sets the background image for the element.The background image attribute is supported by both
browsers. Background Repeat Determines whether and how the background image is repeated. The Repeat attribute is
supported by both browsers.
• No Repeat displays the image once at the beginning of the element. • Repeat tiles the image horizontally and vertically behind the element. • Repeat-x and Repeat-y display a horizontal and vertical band of images, respectively. Images are clipped to fit within the boundaries of the element. Note: Use the Repeat property to redefine the body tag and set a background image that does not tile or repeat. Background Attachment Determines whether the background image is fixed at its original position or scrolls along
with the content. Note that some browsers may treat the Fixed option as Scroll. This is supported by Internet Explorer but not Netscape Navigator. Background Position (X) and Background Position (Y) Specify the initial position of the background image in relation to the element. This can be used to align a background image to the center of the page, both vertically (Y) and
Last updated 3/28/2012
129
USING DREAMWEAVER Creating pages with CSS
horizontally (X). If the attachment property is Fixed, the position is relative to the Document window, not to the element. 4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style block properties You use the Block category of the CSS Rule Definition dialog box to define spacing and alignment settings for tags and properties. 1 Open the CSS Styles panel (Shift+F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Block, then set any of the following style properties. (Leave the
property blank if it is not important to the style.) Word Spacing Sets the spacing between words. To set a specific value, in the pop-up menu, select Value, then enter a numeric value. In the second pop-up menu, select a measurement unit (for example, pixel, points, and so on).
Note: You can specify negative values, but the display depends on the browser. Dreamweaver does not display this attribute in the Document window. Letter Spacing Increases or decreases space between letters or characters. To decrease the space between characters specify a negative value, for example (-4). Letter spacing settings override justified text settings. The Letter Spacing attribute is supported by Internet Explorer 4 and later and Netscape Navigator 6. Vertical Align Specifies the vertical alignment of the element to which it is applied. Dreamweaver displays this
attribute in the Document window only when it is applied to the tag. Text Align Sets how text is aligned within the element. The Text Align attribute is supported by both browsers. Text Indent Specifies how far the first line of text indents. A negative value may be used to create an outdent, but the
display depends on the browser. Dreamweaver displays this attribute in the Document window only when the tag is applied to block-level elements. The Text Indent attribute is supported by both browsers. Whitespace Determines how white space within the element is handled. Select from three options: Normal collapses
white space; Pre handles it as if the text were enclosed in pre tags (that is, all white space, including spaces, tabs, and returns, is respected); Nowrap specifies that the text only wraps when a br tag is encountered. Dreamweaver does not display this attribute in the Document window. The Whitespace attribute is supported by Netscape Navigator and Internet Explorer 5.5. Display Specifies whether an element is displayed and if so how it is displayed. None disables the display of an element
to which it is assigned. 4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style box properties Use the Box category of the CSS Rule Definition dialog box to define settings for tags and properties that control the placement of elements on the page. You can apply settings to individual sides of an element when applying padding and margin settings, or use the Same For All setting to apply the same setting to all sides of an element. 1 Open the CSS Styles panel (Shift + F11) if it isn’t already open.
Last updated 3/28/2012
130
USING DREAMWEAVER Creating pages with CSS
2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Box, and set any of the following style properties. (Leave the property
blank if it is not important to the style.) Width and Height Sets the width and height of the element. Float Sets which side other elements, such as text, AP Divs, tables and so on, will float around an element. Other
elements wrap around the floating element as usual. The Float attribute is supported by both browsers. Clear Defines the sides that do not allow AP elements. If an AP element appears on the clear side, the element with the
clear setting moves below it. The Clear attribute is supported by both browsers. Padding Specifies the amount of space between the content of an element and its border (or margin if there is no
border). Deselect the Same For All option to set the padding for individual sides of the element. Same For All Sets the same padding properties to the Top, Right, Bottom, and Left of the element to which it is applied. Margin Specifies the amount of space between the border of an element (or the padding if there is no border) and another element. Dreamweaver displays this attribute in the Document window only when it is applied to block-level elements (paragraphs, headings, lists, and so on). Deselect Same For All to set the margin for individual sides of the element. Same For All Sets the same margin properties to the Top, Right, Bottom, and Left of the element to which it is applied.
4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style border properties Use the Border category of the CSS Rule Definition dialog box to define settings, such as width, color, and style, for the borders around elements. 1 Open the CSS Styles panel (Shift+F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Border, and set any of the following style properties. (Leave the
property blank if it is not important to the style.) Type Sets the style appearance of the border. The way the style appears depends on the browser. Deselect Same For
All to set the border style for individual sides of the element. Same For All Sets the same border style properties to the Top, Right, Bottom, and Left of the element to which it is
applied. Width Sets the thickness of the element’s border. The Width attribute is supported by both browsers. Deselect Same
For All to set the border width for individual sides of the element. Same For All Sets the same border width to the Top, Right, Bottom, and Left of the element to which it is applied. Color Sets the color of the border. You can set each side’s color independently, but the display depends on the browser. Deselect Same For All to set the border color for individual sides of the element. Same For All Sets the same border color to the Top, Right, Bottom, and Left of the element to which it is applied.
4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Last updated 3/28/2012
131
USING DREAMWEAVER Creating pages with CSS
Define CSS style list properties The List category of the CSS Rule Definition dialog box defines list settings, such as bullet size and type, for list tags. 1 Open the CSS Styles panel (Shift+F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select List, and set any of the following style properties. (Leave the property
blank if it is not important to the style.) List style type Sets the appearance of bullets or numbers. Type is supported by both browsers. List style image Lets you specify a custom image for bullets. Click Browse (Windows) or Choose (Macintosh) to browse to an image, or type the image’s path. List style position Sets whether list item text wraps and indents (outside) or whether the text wraps to the left margin
(inside). 4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style positioning properties The Positioning style properties determine how the content related to the selected CSS style is positioned on the page. 1 Open the CSS Styles panel (Shift+F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Positioning, and then set the style properties you want.
Leave any of the following properties empty if they are not important to the style: Position Determines how the browser should position the selected element as follows:
• Absolute places the content using the coordinates entered in the Placement boxes relative to the nearest absolutelyor relatively-positioned ancestor, or, if no absolutely- or relatively-positioned ancestor exists, to the upper-left corner of the page.
• Relative places the content block using the coordinates entered in the Placement boxes relative to block’s position in the text flow of the document. For example, giving an element a relative position and top and left coordinates of 20px each will shift the element 20px to the right and 20px down from its normal position in the flow. Elements can also be positioned relatively, with or without top, left, right, or bottom coordinates, to establish a context for absolutely-positioned children.
• Fixed places the content using the coordinates entered in the Placement boxes, relative to the top left corner of the browser. The content will remain fixed in this position as the user scrolls the page.
• Static places the content at its location in the text flow. This is the default position of all positionable HTML elements. Visibility Determines the initial display condition of the content. If you do not specify a visibility property, by default
the content inherits the parent tag’s value. The default visibility of the body tag is visible. Select one of the following visibility options:
• Inherit inherits the visibility property of the content’s parent. • Visible displays the content, regardless of the parent’s value. • Hidden hides the content, regardless of the parent’s value.
Last updated 3/28/2012
132
USING DREAMWEAVER Creating pages with CSS
Z-Index Determines the stacking order of the content. Elements with a higher z-index appear above elements with a lower z-index (or none at all). Values can be positive or negative. (If your content is absolutely positioned, it’s easier to change the stacking order using the AP Elements panel). Overflow Determines what happens if the contents of a container (for example, a DIV or a P) exceed its size. These
properties control the expansion as follows:
• Visible increases the container’s size so that all of its contents are visible. The container expands down and to the right.
• Hidden maintains the container’s size and clips any content that doesn’t fit. No scroll bars are provided. • Scroll adds scroll bars to the container regardless of whether the contents exceed the container’s size. Specifically providing scroll bars avoids confusion caused by the appearance and disappearance of scroll bars in a dynamic environment. This option is not displayed in the Document window.
• Auto makes scroll bars appear only when the container’s contents exceed its boundaries. This option is not displayed in the Document window. Placement Specifies the location and size of the content block. How the browser interprets the location depends on the setting for Type. Size values are overridden if the content of the content block exceeds the specified size.
The default units for location and size are pixels. You can also specify the following units: pc (picas), pt (points), in (inches), mm (millimeters), cm (centimeters), (ems), (exs), or % (percentage of the parent’s value). The abbreviations must follow the value without a space: for example, 3mm. Clip Defines the part of the content that is visible. If you specify a clipping region, you can access it with a scripting
language such as JavaScript and manipulate the properties to create special effects such as wipes. These wipes can be set up by using the Change Property behavior. 4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Define CSS style extension properties Extensions style properties include filters, page break, and pointer options. Note: There are a number of other extension properties available in Dreamweaver, but to access them, you need to go through the CSS Styles panel. You can easily see a list of extension properties available by opening the CSS Styles panel (Windows > CSS Styles), clicking the Show Category View button at the bottom of the panel, and expanding the Extensions category. 1 Open the CSS Styles panel (Shift + F11) if it isn’t already open. 2 Double-click an existing rule or property in the top pane of the CSS Styles panel. 3 In the CSS Rule Definition dialog box, select Extensions, and set any of the following style properties. (Leave the
property blank if it is not important to the style.) Page break before Forces a page break during printing either before or after the object controlled by the style. Select
the option you want to set in the pop-up menu. This option is not supported by any 4.0 browser, but support may be provided by future browsers. Cursor Changes the pointer image when the pointer is over the object controlled by the style. Select the option you
want to set in the pop-up menu. Internet Explorer 4.0 and later, and Netscape Navigator 6 support this attribute. Filter Applies special effects to the object controlled by the style, including blur and inversion. Select an effect from
the pop-up menu.
Last updated 3/28/2012
133
USING DREAMWEAVER Creating pages with CSS
4 When you are finished setting these options, select another CSS category on the left side of the panel to set
additional style properties, or click OK.
Edit a CSS rule You can easily edit both internal and external rules that you have applied to a document. When you edit a CSS style sheet that controls the text in your document, you instantly reformat all of the text controlled by that CSS style sheet. Edits to an external style sheet affect all the documents linked to it. You can set an external editor to use for editing style sheets.
Edit a rule in the CSS Styles panel (Current mode) 1 Open the CSS Styles panel by selecting Window > CSS Styles. 2 Click the Current button at the top of the CSS Styles panel. 3 Select a text element in the current page to display its properties. 4 Do one of the following:
• Double-click a property in the Summary for Selection pane to display the CSS Rule Definition dialog box, and then make your changes.
• Select a property in the Summary for Selection pane, and then edit the property in the Properties pane below. • Select a rule in the Rules pane, and then edit the rule’s properties in the Properties pane below. Note: You can change the double-clicking behavior for editing CSS, as well as other behaviors, by changing Dreamweaver preferences.
Edit a rule in the CSS Styles panel (All mode) 1 Open the CSS Styles panel by selecting Window > CSS Styles. 2 Click the All button at the top of the CSS Styles panel. 3 Do one of the following:
• Double-click a rule in the All Rules pane to display the CSS Rule Definition dialog box, and then make your changes.
• Select a rule in the All Rules pane, and then edit the rule’s properties in the Properties pane below. • Select a rule in the All Rules pane, and then click the Edit Style button in the lower-right corner of the CSS Styles panel. Note: You can change the double-clicking behavior for editing CSS, as well as other behaviors, by changing Dreamweaver preferences.
Change the name of a CSS selector 1 In the CSS Styles panel (All mode) select the selector you want to change. 2 Click the selector again to make the name editable. 3 Make your changes and press Enter (Windows) or Return (Macintosh).
Last updated 3/28/2012
134
USING DREAMWEAVER Creating pages with CSS
More Help topics “Set text properties in the Property inspector” on page 214
Add a property to a CSS rule You can use the CSS Styles panel to add properties to rules. 1 In the CSS Styles panel (Window > CSS), select a rule in the All Rules pane (All mode), or select a property in the
Summary for Selection pane (Current mode). 2 Do one of the following:
• If Show Only Set Properties view is selected in the Properties pane, click the Add Properties link and add a property. • If Category view or List view is selected in the Properties pane, fill in a value for the property you want to add.
Apply, remove, or rename CSS class styles Class styles are the only type of CSS style that can be applied to any text in a document, regardless of which tags control the text. All class styles associated with the current document are displayed in the CSS Styles panel (with a period [.] preceding their name) and in the Style pop-up menu of the text Property inspector. You’ll see most styles updated immediately, however, you should preview your page in a browser to verify a style was applied as expected. When you apply two or more styles to the same text, the styles may conflict and produce unexpected results. When previewing styles defined in an external CSS style sheet, be sure to save the style sheet to ensure that your changes are reflected when you preview the page in a browser.
More Help topics “About Cascading Style Sheets” on page 116 “About cascading styles” on page 118 “The CSS Styles panel” on page 120
Apply a CSS class style 1 In the document, select the text to which you want to apply a CSS style.
Place the insertion point in a paragraph to apply the style to the entire paragraph. If you select a range of text within a single paragraph, the CSS style affects only the selected range. To specify the exact tag to which the CSS style should be applied, select the tag in the tag selector located at the lower left of the Document window. 2 To apply a class style, do one of the following:
• In the CSS Styles panel (Window > CSS Styles), select All mode, right-click the name of the style you want to apply, and select Apply from the context menu.
• In the HTML Property inspector, select the class style you want to apply from the Class pop-up menu.
Last updated 3/28/2012
135
USING DREAMWEAVER Creating pages with CSS
• In the Document window, right-click (Windows) or Control-click (Macintosh) the selected text, and in the context menu, select CSS Styles and then select the style you want to apply.
• Select Format > CSS Styles, and in the submenu select the style you want to apply.
Remove a class style from a selection 1 Select the object or text you want to remove the style from. 2 In the HTML Property inspector (Window > Properties), select None from the Class pop-up menu.
Rename a class style 1 In the CSS styles panel, right-click the CSS class style you want to rename and select Rename Class.
You can also rename a class by selecting Rename Class from the CSS Styles panel options menu. 2 In the Rename Class dialog box, make sure that the class you want to rename is selected in the Rename Class pop-up
menu. 3 In the New Name text box, enter the new name for the new class and click OK.
If the class you’re renaming is internal to the head of the current document, Dreamweaver changes the class name as well as all instances of the class name in the current document. If the class you’re renaming is in an external CSS file, Dreamweaver opens and changes the class name in the file. Dreamweaver also launches a site-wide Find and Replace dialog box so that you can search for all instances of the old class name in your site.
Move/export CSS rules The CSS management features in Dreamweaver make it easy for you to move or export CSS rules to different locations. You can move rules from document to document, from the head of a document to an external style sheet, between external CSS files, and more. Note: If the rule you’re trying to move conflicts with a rule in the destination style sheet, Dreamweaver displays the Rule With Same Name Exists dialog box. If you elect to move the conflicting rule, Dreamweaver places the moved rule immediately adjacent to the conflicting rule in the destination style sheet.
More Help topics “Insert code with the Coding toolbar” on page 291
Move/export CSS rules to a new style sheet 1 Do one of the following:
• In the CSS Styles panel, select the rule or rules you want to move. Then right-click the selection and select Move CSS Rules from the context menu. To select multiple rules, Control-click (Windows) or Command-click (Macintosh) the rules you want to select.
• In Code view, select the rule or rules you want to move. Then right-click the selection and select CSS Styles > Move CSS Rules from the context menu. Note: Partial selection of a rule will result in the relocation of the entire rule. 2 In the Move To External Style Sheet dialog box, select the new style sheet option and click OK.
Last updated 3/28/2012
136
USING DREAMWEAVER Creating pages with CSS
3 In the Save Style Sheet File As dialog box, enter a name for the new style sheet and click Save.
When you click Save, Dreamweaver saves a new style sheet with the rules you selected and attaches it to the current document. You can also move rules by using the Coding toolbar. The Coding toolbar is available in Code view only.
Move/export CSS rules to an existing style sheet 1 Do one of the following:
• In the CSS Styles panel, select the rule or rules you want to move. Then right-click the selection and select Move CSS Rules from the context menu. To select multiple rules, Control-click (Windows) or Command-click (Macintosh) the rules you want to select.
• In Code view, select the rule or rules you want to move. Then right-click the selection and select CSS Styles > Move CSS Rules from the context menu. Note: Partial selection of a rule will result in the relocation of the entire rule. 2 In the Move To External Style Sheet dialog box, select an existing style sheet from the pop-up menu or browse to
an existing style sheet and click OK. Note: The pop-up menu displays all style sheets that are linked to the current document. You can also move rules by using the Coding toolbar. The Coding toolbar is available in Code view only.
Rearrange or move CSS rules by dragging ❖ In the CSS Styles panel (All mode), select a rule and drag it rule to the desired location. You can select and drag to
re-order rules within a style sheet, or move a rule to another style sheet or the document head. You can move more than one rule at a time by Control-clicking (Windows) or Command-clicking (Macintosh) multiple rules to select them.
Select multiple rules before moving them ❖ In the CSS Styles panel, Control-click (Windows) or Command-click (Macintosh) the rules you want to select.
Convert inline CSS to a CSS rule In-line styles are not recommended best practices. To make your CSS cleaner and more organized, you can convert inline styles to CSS rules that reside in the head of the document or in an external style sheet. 1 In Code view (View > Code), select the entire style attribute that contains the inline CSS you want to convert 2 Right-click and select CSS Styles > Convert Inline CSS to Rule. 3 In the Convert Inline CSS dialog box, enter a class name for the new rule, and then do one of the following:
• Specify a style sheet where you want the new CSS rule to appear and click OK. • Select the head of the document as the location where you want the new CSS rule to appear and click OK. You can also convert rules by using the Coding toolbar. The Coding toolbar is available in Code view only.
Last updated 3/28/2012
137
USING DREAMWEAVER Creating pages with CSS
More Help topics “Insert code with the Coding toolbar” on page 291
Link to an external CSS style sheet When you edit an external CSS style sheet, all documents linked to that CSS style sheet are updated to reflect those edits. You can export the CSS styles found in a document to create a new CSS style sheet, and attach or link to an external style sheet to apply the styles found there. You can attach to your pages any style sheet that you create or copy into your site. In addition, Dreamweaver is shipped with prebuilt style sheets that can be automatically moved into your site and attached to your pages. 1 Open the CSS Styles panel by doing one of the following:
• Select Window > CSS Styles. • Press Shift + F11. 2 In the CSS Styles panel, click the Attach Style Sheet button. (It’s in the lower-right corner of the panel.) 3 Do one of the following:
• Click Browse to browse to an external CSS style sheet. • Type the path to the style sheet in the File/URL box. 4 For Add As, select one of the options:
• To create a link between the current document and an external style sheet, select Link. This creates a link href tag in the HTML code, and references the URL where the published style sheet is located. This method is supported by both Microsoft Internet Explorer and Netscape Navigator.
• You cannot use a link tag to add a reference from one external style sheet to another. If you want to nest style sheets, you must use an import directive. Most browsers also recognize the import directive within a page (rather than just within style sheets). There are subtle differences in how conflicting properties are resolved when overlapping rules exist within external style sheets that are linked versus imported to a page. If you want to import, rather than link to, an external style sheet, select Import. 5 In the Media pop-up menu, specify the target medium for the style sheet.
For more information on media-dependent style sheets, see the World Wide Web Consortium website at www.w3.org/TR/CSS21/media.html. 6 Click the Preview button to verify that the style sheet applies the styles you want to the current page.
If the styles applied are not what you expect them to be, click Cancel to remove the style sheet. The page will revert to its previous appearance. 7 Click OK.
More Help topics “Create a page based on a Dreamweaver sample file” on page 62
Last updated 3/28/2012
138
USING DREAMWEAVER Creating pages with CSS
Edit a CSS style sheet A CSS style sheet typically includes one or more rules. You can edit an individual rule in a CSS style sheet using the CSS Styles panel, or if you prefer, you can work directly in the CSS style sheet. 1 In the CSS Styles panel (Window > CSS Styles), select All mode. 2 In the All rules pane, double-click the name of the style sheet you want to edit. 3 In the Document window, modify the style sheet as desired, and then save the style sheet.
Format CSS code You can set preferences that control the format of your CSS code whenever you create or edit a CSS rule using the Dreamweaver interface. For example, you can set preferences that will place all CSS properties on separate lines, place a blank line between CSS rules, and so on. When you set CSS code formatting preferences, the preferences you select are automatically applied to all new CSS rules that you create. You can, however, also apply these preferences manually to individual documents. This might be useful if you have an older HTML or CSS document that needs formatting. Note: CSS code formatting preferences apply to CSS rules in external or embedded style sheets only (not to in-line styles)
More Help topics “Change the code format” on page 283
Set CSS code formatting preferences 1 Select Edit > Preferences. 2 In the Preferences dialog box, select the Code Format category. 3 Next to Advanced Formatting, click the CSS button. 4 In the CSS Source Format Options dialog box, select the options that you want to apply to your CSS source code.
A preview of the CSS as it would look according to the options you’ve selected appears in the Preview window below. Indent Properties With Sets the indentation value for properties within a rule. You can specify tabs or spaces. Each Property On A Separate Line Places each property within a rule on a separate line. Opening Brace On Separate Line Places the opening brace for a rule on a separate line from the selector. Only If More Than One Property Places single-property rules on the same line as the selector. All Selectors For A Rule On Same Line Places all selectors for the rule on the same line. Blank Line Between Rules Inserts a blank line between each rule.
5 Click OK.
Note: CSS code formatting also inherits the Line Break Type preference that you set in the Code Format category of the Preferences dialog box.
Last updated 3/28/2012
139
USING DREAMWEAVER Creating pages with CSS
Format CSS code in a CSS style sheet manually 1 Open a CSS style sheet. 2 Select Commands > Apply Source Formatting.
The formatting options you set in CSS code formatting preferences are applied to the entire document. You cannot format individual selections.
Format embedded CSS code manually 1 Open an HTML page that contains CSS embedded in the head of the document. 2 Select any part of the CSS code. 3 Select Commands > Apply Source Formatting To Selection.
The formatting options you set in CSS code formatting preferences are applied to all CSS rules in the head of the document only. Note: You can select Commands > Apply Source Formatting to format the entire document according to your specified code formatting preferences.
Disable/Enable CSS The Disable/Enable CSS Property feature lets you comment out portions of CSS from the CSS Styles panel, without having to make changes directly in the code. When you comment out portions of the CSS, you can see what kinds of effects particular properties and values have on your page. When you disable a CSS property, Dreamweaver adds CSS comment tags and a [disabled] label to the CSS property you’ve disabled. You can then easily re-enable or delete the disabled CSS property according to your preference. For a video overview from the Dreamweaver engineering team about working with CSS Disable/Enable, see www.adobe.com/go/dwcs5css_en. 1 In the Properties pane of the CSS Styles panel (Window > CSS Styles), select the property you want to disable. 2 Click the Disable/Enable CSS Property icon in the lower-right corner of the Properties pane. The icon also appears
if you hover to the left of the property itself. Once you click the Disable/Enable CSS Property icon, a Disabled icon appears to the left of the property. To reenable the property, click the Disabled icon, or right-click (Windows) or Control-click (Macintosh OS) the property and select Enable. 3 (Optional) To enable or delete all of the disabled properties in a selected rule, right-click (Windows) or Control-
click (Macintosh OS) any rule or property in which properties are disabled, and selectEnable All Disabled in Selected Rule, or Delete all Disabled in Selected rule.
Inspect CSS in Live view Inspect mode works together with Live View to help you quickly identify HTML elements and their associated CSS styles. With Inspect mode turned on, you can hover over elements on your page to see the CSS box model attributes for any block-level element. Note: For more information on the CSS box model, see the CSS 2.1 specification.
Last updated 3/28/2012
140
USING DREAMWEAVER Creating pages with CSS
In addition to seeing a visual representation of the box model in Inspect mode, you can also use the CSS Styles panel as you hover over elements in the Document window. When you have the CSS Styles panel open in Current mode and hover over an element on the page, the rules and properties in the CSS Styles panel automatically update to show you the rules and properties for that element. Additionally, any view or panel related to the element you’re hovering over updates as well (for example, Code view, the Tag selector, the Property inspector, and so on). 1 With your document open in the Document window, click the Inspect button (next to the Live View button in the
Document toolbar). Note: If you’re not already in Live view, Inspect mode automatically enables it. 2 Hover over elements on the page to see the CSS box model. Inspect mode highlights different colors for the border,
margin, padding, and content. 3 (Optional) Press the left arrow on your computer keyboard to highlight the parent of the currently highlighted
element. Press the right arrow to return to highlighting for the child element. 4 (Optional) Click an element to lock a highlight selection.
Note: Clicking an element to lock a highlight selection turns off Inspect mode.
More Help topics “Previewing pages in Dreamweaver” on page 272 “The CSS Styles panel” on page 120
Check for cross-browser CSS rendering issues The Browser Compatibility Check (BCC) feature helps you locate combinations of HTML and CSS that have problems in certain browsers. When you run a BCC on an open file, Dreamweaver scans the file and reports any potential CSS rendering issues in the Results panel. A confidence rating, indicated by a quarter, half, three-quarter, or completely filled circle, indicates the likelihood of the bug’s occurrence (a quarter-filled circle indicating a possible occurrence, and a completely-filled circle indicating a very likely occurrence). For each potential bug that it finds, Dreamweaver also provides a direct link to documentation about the bug on Adobe CSS Advisor, a website that details commonly known browser rendering bugs, and offers solutions for fixing them. By default, the BCC feature checks against the following browsers: Firefox 1.5; Internet Explorer (Windows) 6.0 and 7.0; Internet Explorer (Macintosh) 5.2; Netscape Navigator 8.0; Opera 8.0 and 9.0; Safari 2.0. This feature replaces the former Target Browser Check feature, but retains the CSS functionality of that feature. That is, the new BCC feature still tests the code in your documents to see if any of the CSS properties or values are unsupported by your target browsers. Three levels of potential browser-support problems can arise:
• An error indicates CSS code that might cause a serious visible problem in a particular browser, such as causing parts of a page to disappear. (Error is the default designation for browser support problems, so in some cases, code with an unknown effect is also marked as an error.)
• A warning indicates a piece of CSS code that isn’t supported in a particular browser, but that won’t cause any serious display problems.
• An informational message indicates code that isn’t supported in a particular browser, but that has no visible effect. Browser compatibility checks do not alter your document in any way.
Last updated 3/28/2012
141
USING DREAMWEAVER Creating pages with CSS
More Help topics “Validate XML documents” on page 306 CSS Advisor
Run a browser compatibility check ❖ Select File > Check Page > Browser Compatibility.
Select the element affected by a found issue ❖ Double-click the issue in the Results panel.
Jump to the next or previous found issue in the code ❖ Select Next Issue or Previous Issue from the Browser Compatibility Check menu in the Document toolbar.
Select browsers for Dreamweaver to check against 1 In the Results panel (Window > Results), select the Browser Compatibility Check tab. 2 Click the green arrow in the upper-left corner of the Results panel and select Settings. 3 Select the checkbox next to each browser you want to check against. 4 For each selected browser, select a minimum version to check against from the corresponding pop-up menu.
For example, to see if CSS rendering bugs might appear in Internet Explorer 5.0 and later and Netscape Navigator 7.0 and later, select the checkboxes next to those browser names, and select 5.0 from the Internet Explorer pop-up menu and 7.0 from the Netscape pop-up menu.
Exclude an issue from the browser compatibility check 1 Run a browser compatibility check. 2 In the Results panel, Right-click (Windows) or Control-click (Macintosh) the issue that you want to exclude from
future checking. 3 Select Ignore Issue from the context menu.
Edit the Ignored Issues list 1 In the Results panel (Window > Results), select the Browser Compatibility Check tab. 2 Click the green arrow in the upper-left corner of the Results panel and select Edit Ignored Issues List. 3 In the Exceptions.xml file, find the issue that you want deleted from the Ignored Issues list and delete it. 4 Save and close the Exceptions.xml file.
Save a browser compatibility check report 1 Run a browser compatibility check. 2 Click the Save Report button on the left side of the Results panel.
Hover over buttons in the Results panel to see button tool tips.
Last updated 3/28/2012
142
USING DREAMWEAVER Creating pages with CSS
Note: Reports are not saved automatically; if you want to keep a copy of a report, you must follow the above procedure to save it.
View a browser compatibility check report in a browser 1 Run a browser compatibility check. 2 Click the Browse Report button on the left side of the Results panel.
Hover over buttons in the Results panel to see button tool tips.
Open the Adobe CSS Advisor website 1 In the Results panel (Window > Results), select the Browser Compatibility Check tab. 2 Click the link text at the bottom right of the panel.
Use Design-Time style sheets Design-Time style sheets allow you to show or hide design applied by a CSS style sheet as you work in a Dreamweaver document. For example, you can use this option to include or exclude the effect of a Macintosh-only or a Windowsonly style sheet as you design a page. Design-Time style sheets only apply while you are working in the document; when the page is displayed in a browser window, only the styles that are actually attached to or embedded in the document appear in a browser. Note: You can also enable or disable styles for an entire page using the Style Rendering toolbar. To display the toolbar, select View > Toolbars > Style Rendering. The Toggle Displaying of CSS Styles button (the right-most button) works independently of the other media buttons on the toolbar. To use a Design-time style sheet, follow these steps. 1 Open the Design-Time Style Sheets dialog box by doing one of the following:
• Right-click in the CSS Styles panel, and in the context menu select Design-time. • Select Format > CSS Styles > Design-time. 2 In the dialog box, set options to show or hide a selected style sheet:
• To display a CSS style sheet at design-time, click the Plus (+) button above Show Only At Design Time, then in the Select a Style Sheet dialog box, browse to the CSS style sheet you want to show.
• To hide a CSS style sheet, click the Plus (+) button above Hide At Design-Time, then in the Select a Style Sheet dialog box, browse to the CSS style sheet you want to show.
• To remove a style sheet from either list, click the style sheet you want to remove, then click the appropriate Minus (–) button. 3 Click OK to close the dialog box.
The CSS Styles panel updates with the selected style sheet’s name along with an indicator, “hidden” or “design,” to reflect the style sheet’s status.
More Help topics “Style Rendering toolbar overview” on page 10
Last updated 3/28/2012
143
USING DREAMWEAVER Creating pages with CSS
Use Dreamweaver sample style sheets Dreamweaver provides sample style sheets that you can apply to your pages or that you can use as starting points to develop your own styles. 1 Open the CSS Styles panel by doing one of the following:
• Select Window > CSS Styles. • Press Shift+F11. 2 In the CSS Styles panel, click the Attach External Style Sheet button. (It’s in the lower-right corner of the panel.) 3 In the Attach External Style Sheet dialog box, click Sample Style Sheets. 4 In the Sample Style Sheets dialog box, select a style sheet from the list box.
As you select style sheets within the list box, the Preview pane displays the text and color formatting of the selected style sheet. 5 Click the Preview button to apply the style sheet and verify that it applies the styles you want to the current page.
If the styles applied are not what you expect them to be, select another style sheet from the list, and click Preview to see those styles. 6 By default, Dreamweaver saves the style sheet in a folder named CSS just below the root of the site you defined for
your page. If that folder does not exist, Dreamweaver creates it. You can save the file to another location by clicking Browse and browsing to another folder. 7 When you find a style sheet whose formatting rules meet your design criteria, click OK.
Update CSS style sheets in a Contribute site Adobe Contribute users can’t make changes to a CSS style sheet. To change a style sheet for a Contribute site, use Dreamweaver. 1 Edit the style sheet using the Dreamweaver style-sheet-editing tools. 2 Tell all of the Contribute users who are working on the site to publish pages that use that style sheet, then re-edit
those pages to view the new style sheet. The following are important factors to keep in mind when updating style sheets for a Contribute site:
• If you make changes to a style sheet while a Contribute user is editing a page that uses that style sheet, the user won’t see the changes to the style sheet until they publish the page.
• If you delete a style from a style sheet, the style name is not deleted from pages that use that style sheet, but since the style no longer exists, it isn’t displayed the way the Contribute user may expect. Thus, if a user tells you that nothing happens when they apply a particular style, the problem may be that the style has been deleted from the style sheet.
Last updated 3/28/2012
144
USING DREAMWEAVER Creating pages with CSS
Laying out pages with CSS About CSS page layout A CSS page layout uses the Cascading Style Sheets format, rather than traditional HTML tables or frames, to organize the content on a web page. The basic building block of the CSS layout is the div tag—an HTML tag that in most cases acts as a container for text, images, and other page elements. When you create a CSS layout, you place div tags on the page, add content to them, and position them in various places. Unlike table cells, which are restricted to existing somewhere within the rows and columns of a table, div tags can appear anywhere on a web page. You can position div tags absolutely (by specifying x and y coordinates), or relatively (by specifying their distance from other page elements). You can also position div tags by specifying floats, paddings, and margins—the preferred method by today’s web standards. Creating CSS layouts from scratch can be difficult because there are so many ways to do it. You can create a simple two-column CSS layout by setting floats, margins, paddings, and other CSS properties in a nearly infinite number of combinations. Additionally, the problem of cross-browser rendering causes certain CSS layouts to display properly in some browsers, and display improperly in others. Dreamweaver makes it easy for you to build pages with CSS layouts by providing 16 pre-designed layouts that work across different browsers. Using the pre-designed CSS layouts that come with Dreamweaver is the easiest way to create a page with a CSS layout, but you can also create CSS layouts using Dreamweaver absolutely-positioned elements (AP elements). An AP element in Dreamweaver is an HTML page element—specifically, a div tag, or any other tag—that has an absolute position assigned to it. The limitation of Dreamweaver AP elements, however, is that since they are absolutely positioned, their positions never adjust on the page according to the size of the browser window. If you are an advanced user, you can also insert div tags manually and apply CSS positioning styles to them to create page layouts.
About CSS page layout structure Before proceeding with this section, you should be familiar with basic CSS concepts. The basic building block of the CSS layout is the div tag—an HTML tag that in most cases acts as a container for text, images, and other page elements. The following example shows an HTML page that contains three separate div tags: one large “container” tag, and two other tags—a sidebar tag, and a main content tag—within the container tag.
B
A C
A. Container div B. Sidebar div C. Main Content div
Following is the code for all three div tags in the HTML:
Last updated 3/28/2012
145
USING DREAMWEAVER Creating pages with CSS
tag in the tag selector at the lower-left corner of the Document window. • Click in a table cell, then select Modify > Table > Select Table. • Click in a table cell, click the table header menu, then select Select Table. Selection handles appear on the selected table’s lower and right edges.
Select individual or multiple rows or columns 1 Position the pointer to point to the left edge of a row or the top edge of a column. 2 When the pointer changes to a selection arrow, click to select a row or column, or drag to select multiple rows or
columns.
Select a single column 1 Click in the column. 2 Click the column header menu and choose Select Column.
Select a single cell ❖ Do one of the following:
• Click in the cell, then select the tag in the tag selector at the lower-left corner of the Document window. • Control-click (Windows) or Command-click (Macintosh) in the cell. • Click in the cell and select Edit >Select All. Select Edit > Select All again when a cell is selected to select the entire table.
Select a line or a rectangular block of cells ❖ Do one of the following:
• Drag from a cell to another cell. • Click in one cell, Control-click (Windows) or Command-click (Macintosh) in the same cell to select it, then Shiftclick another cell.
Last updated 3/28/2012
172
USING DREAMWEAVER Laying out pages with HTML
All of the cells within the linear or rectangular region defined by the two cells are selected.
Select nonadjacent cells ❖ Control-click (Windows) or Command-click (Macintosh) the cells, rows, or columns you want to select.
If each cell, row, or column you Control-click or Command-click isn’t already selected, it’s added to the selection. If it is already selected, it’s removed from the selection.
Change the highlight color for table elements 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Highlighting from the category list on the left, make either of the following changes, and click OK.
• To change the highlighting color for table elements, click the Mouse-Over color box, then select a highlight color using the color picker (or enter the hexadecimal value for the highlight color in the text box).
• To enable or disable highlighting for table elements, select or deselect the Show option for Mouse-Over. Note: These options affect all objects, such as absolutely-positioned elements (AP elements), that Dreamweaver highlights when you move the pointer over them.
Set table properties You can use the Property inspector to edit tables. 1 Select a table. 2 In the Property inspector (Window > Properties), change properties as necessary. Table Id An ID for the table. Rows and Cols The number of rows and columns in the table. W The width of the table in pixels, or as a percentage of the browser window’s width.
Note: You usually don’t need to set the height of a table. CellPad The number of pixels between a cell’s content and the cell boundaries. CellSpace The number of pixels between adjacent table cells. Align Determines where the table appears, relative to other elements in the same paragraph, such as text or images.
Left aligns the table to the left of other elements (so that text in the same paragraph wraps around the table to the right); Right aligns the table to the right of other elements (with text wrapping around it to the left); and Center centers the table (with text appearing above and/or below the table). Default indicates that the browser should use its default alignment. When alignment is set to Default, other content is not displayed next to the table. To display a table next to other content, use Left or Right alignment. Border Specifies the width, in pixels, of the table’s borders.
Last updated 3/28/2012
173
USING DREAMWEAVER Laying out pages with HTML
If you don’t explicitly assign values for the border, cell spacing, and cell padding, most browsers display the table with the border and cell padding set to 1 and cell spacing set to 2. To ensure that browsers display the table with no padding or spacing, set Border to 0, Cell Padding and Cell Spacing to 0. To view cell and table boundaries when the border is set to 0, select View > Visual Aids > Table Borders. Class sets a CSS class on the table.
Note: You might need to expand the Table Property inspector to see the following options. To expand the Table Property inspector, click the expander arrow in the lower-right corner. Clear Column Widths and Clear Row Heights delete all explicitly specified row height or column width values from the
table. Convert Table Widths To Pixels and Convert Table Heights To Pixels set the width or height of each column in the
table to its current width in pixels (also sets the width of the whole table to its current width in pixels). Convert Table Widths To Percent and Convert Table Heights To Percent set the width or height of each column in the
table to its current width expressed as a percentage of the Document window’s width (also sets the width of the whole table to its current width as a percentage of the Document window’s width). If you entered a value in a text box, press Tab or Enter (Windows) or Return (Macintosh) to apply the value.
Set cell, row, or column properties You can use the Property inspector to edit cells and rows in a table. 1 Select the column or row. 2 In the Property inspector (Window > Properties), set the following options: Horz Specifies the horizontal alignment of the contents of a cell, row, or column. You can align the contents to the left,
right, or center of the cells, or you can indicate that the browser should use its default alignment (usually left for regular cells and center for header cells). Vert Specifies the vertical alignment of the contents of a cell, row, or column. You can align the contents to the top,
middle, bottom, or baseline of the cells, or indicate that the browser should use its default alignment (usually middle). W and H The width and height of selected cells in pixels, or as a percentage of the entire table’s width or height. To specify a percentage, follow the value with a percent symbol (%). To let the browser determine the proper width or height based on the contents of the cell and the widths and heights of the other columns and rows, leave the field blank (the default).
By default, a browser chooses a row height and column width to accommodate and the widest image or the longest line in a column. This is why a column sometimes becomes much wider than the other columns in the table when you add content to it. Note: You can specify a height as a percentage of the total table height, but the row may not display at the specified percentage height in browsers. Bg The background color for a cell, column, or row, chosen with the color picker. Merge Cells Combines selected cells, rows, or columns into one cell. You can merge cells only if they form a rectangular or linear block. Split Cell Divides a cell, creating two or more cells. You can split only one cell at a time; this button is disabled if more
than one cell is selected.
Last updated 3/28/2012
174
USING DREAMWEAVER Laying out pages with HTML
No Wrap Prevents line wrapping, keeping all the text in a given cell on a single line. If No Wrap is enabled, cells widen
to accommodate all data as you type it or paste it into a cell. (Normally, cells expand horizontally to accommodate the longest word or widest image in the cell, then expand vertically as necessary to accommodate other contents.) Header Formats the selected cells as table header cells. The contents of table header cells are bold and centered by
default. You can specify widths and heights as either pixels or percentages, and you can convert from pixels to percentages and back. Note: When you set properties on a column, Dreamweaver changes the attributes of the td tag corresponding to each cell in the column. When you set certain properties for a row, however, Dreamweaver changes the attributes of the tr tag rather than changing the attributes of each td tag in the row. When you’re applying the same format to all the cells in a row, applying the format to the tr tag produces cleaner, more concise HTML code. 3 Press Tab or Enter (Windows) or Return (Macintosh) to apply the value.
Use Expanded Tables mode for easier table editing Expanded Tables mode temporarily adds cell padding and spacing to all tables in a document and increases the tables’ borders to make editing easier. This mode enables you to select items in tables or precisely place the insertion point. For example, you might expand a table to place the insertion point to the left or right of an image, without inadvertently selecting the image or table cell.
B
A
A. Table in Standard mode B. Table in Expanded tables mode
Note: After you make your selection or place the insertion point, you should return to the Standard mode of Design view to make your edits. Some visual operations, such as resizing, will not give expected results in Expanded Tables mode.
Switch to Expanded Tables mode 1 If you are working in Code view, select View > Design or View > Code And Design (you cannot switch to Expanded
Tables mode in Code view). 2 Do one of the following:
• Select View > Table Mode > Expanded Tables Mode. • In the Layout category of the Insert panel, click Expanded Tables Mode. A bar labeled Expanded Tables Mode appears across the top of the Document window. Dreamweaver adds cell padding and spacing to all tables on the page and increases the tables’ borders.
Switch out of Expanded Tables mode ❖ Do one of the following:
• Click Exit in the bar labeled Expanded Tables Mode at the top of the Document window. • Select View > Table Mode > Standard Mode.
Last updated 3/28/2012
175
USING DREAMWEAVER Laying out pages with HTML
• In the Layout category of the Insert panel, click Standard Mode.
Format tables and cells You can change the appearance of tables by setting properties for the table and its cells or by applying a preset design to the table. Before you set table and cell properties, be aware that the order of precedence for formatting is cells, rows, and tables. To format the text inside a table cell, use the same procedures you would use to format text outside of a table.
Change the format of a table, row, cell, or column 1 Select a table, cell, row, or column. 2 In the Property inspector (Window > Properties), click the expander arrow in the lower-right corner and change
properties as necessary. 3 Change the properties as necessary.
For more information on the options, click the Help icon on the Property inspector. Note: When you set properties on a column, Dreamweaver changes the attributes of the td tag corresponding to each cell in the column. When you set certain properties for a row, however, Dreamweaver changes the attributes of the tr tag rather than changing the attributes of each td tag in the row, When you’re applying the same format to all the cells in a row, applying the format to the tr tag produces cleaner, more concise HTML code.
Add or edit accessibility values for a table in Code view ❖ Edit the appropriate attributes in the code.
To quickly locate the tags in the code, click in the table, then select the tag in the tag selector at the bottom of the Document window.
Add or edit accessibility values for a table in Design view • To edit the table caption, highlight the caption and type a new caption. • To edit the caption alignment, place the insertion point in the table caption, right-click (Windows) or Control-click (Macintosh), then select Edit Tag Code.
• To edit the table summary, select the table, right-click (Windows) or Control-click (Macintosh), then select Edit Tag Code.
Resizing tables, columns, and rows Resizing tables You can resize an entire table or individual rows and columns. When you resize an entire table, all of the cells in the table change size proportionately. If a table’s cells have explicit widths or heights specified, resizing the table changes the visual size of the cells in the Document window but does not change the specified widths and heights of the cells. You can resize a table by dragging one of its selection handles. Dreamweaver displays the table width, along with a table header menu, at the top or bottom of the table when the table is selected or the insertion point is in the table. Sometimes the column widths set in the HTML code do not match their apparent widths on the screen. When this happens, you can make the widths consistent. Table and column widths and header menus appear in Dreamweaver to help you lay out your tables; you can enable or disable the widths and menus as necessary.
Last updated 3/28/2012
176
USING DREAMWEAVER Laying out pages with HTML
Resizing columns and rows You can change the width of a column or the height of a row in the Property inspector or by dragging the borders of the column or row. If you have trouble resizing, you can clear the column widths or row heights and start over. Note: You can also change cell widths and heights directly in the HTML code using Code view. Dreamweaver displays column widths, along with column header menus, at the tops or bottoms of columns when the table is selected or the insertion point is in the table; you can enable or disable the column header menus as necessary.
More Help topics “Working with page code” on page 276
Resize tables, columns, and rows Resize a table ❖ Select the table.
• To resize the table horizontally, drag the selection handle on the right. • To resize the table vertically, drag the selection handle on the bottom. • To resize the table in both dimensions, drag the selection handle at the lower-right corner.
Change a column’s width and keep the overall table width ❖ Drag the right border of the column you want to change.
The width of the adjacent column also changes, so you actually resize two columns. Visual feedback shows you how the columns will adjust; the overall table width does not change.
Note: In tables with percentage-based widths (not pixels), if you drag the right border of the rightmost column, the entire table’s width changes, and all of the columns grow wider or narrow proportionately.
Change a column’s width and maintain the size of the other columns ❖ Hold the Shift key and drag the column’s border.
The width of one column changes. Visual feedback shows you how the columns will adjust; the overall table width changes to accommodate the column you are resizing.
Change a row’s height visually ❖ Drag the lower border of the row.
Last updated 3/28/2012
177
USING DREAMWEAVER Laying out pages with HTML
Make column widths in code consistent with visual widths 1 Click in a cell. 2 Click the table header menu, then select Make All Widths Consistent.
Dreamweaver resets the width specified in the code to match the visual width.
Clear all set widths or heights in a table 1 Select the table. 2 Do one of the following:
• Select Modify > Table > Clear Cell Widths, or Modify > Table > Clear Cell Heights. • In the Property inspector, (Window > Properties), click the Clear Row Heights button Widths button
or the Clear Column
.
• Click the table header menu, then selectClear All Heights or Clear All Widths.
Clear a column’s set width ❖ Click in the column, click the column header menu, and select Clear Column Width.
Enable or disable table and column widths and menus 1 Select View > Visual Aids > Table Widths. 2 Right-click (Windows) or Control-click (Macintosh) in the table, then select Table > Table Widths.
Add and remove rows and columns To add and remove rows and columns, use the Modify > Table or column header menu. Pressing Tab in the last cell of a table automatically adds another row to the table.
Add a single row or column ❖ Click in a cell and do one of the following:
• Select Modify > Table > Insert Row or Modify > Table > Insert Column. A row appears above the insertion point or a column appears to the left of the insertion point.
Last updated 3/28/2012
178
USING DREAMWEAVER Laying out pages with HTML
• Click the column header menu, and then select Insert Column Left or Insert Column Right.
Add multiple rows or columns 1 Click in a cell. 2 Select Modify > Table > Insert Rows Or Columns, complete the dialog box, and click OK. Insert Indicates whether to insert rows or columns. Number of Rows or Number of Columns The number of rows or columns to insert. Where Specifies whether the new rows or columns should appear before or after the row or column of the selected cell.
Delete a row or column ❖ Do one of the following:
• Click in a cell within the row or column you want to delete, then select Modify > Table > Delete Row, or Modify > Table > Delete Column.
• Select a complete row or column, then select Edit > Clear or press Delete.
Add or delete rows or columns using the Property inspector 1 Select the table. 2 In the Property inspector (Windows > Properties), do one of the following:
• To add or delete rows, increase or decrease the Rows value. • To add or delete columns, increase or decrease the Cols value. Note: Dreamweaver does not warn you if you are deleting rows and columns that contain data.
Split and merge cells Use the Property inspector or the commands in the Modify > Table submenu to split or merge cells.
Merge two or more cells in a table 1 Select the cells in a contiguous line and in the shape of a rectangle.
In the following illustration, the selection is a rectangle of cells, so the cells can be merged.
Last updated 3/28/2012
179
USING DREAMWEAVER Laying out pages with HTML
In the following illustration, the selection is not a rectangle, so the cells can’t be merged.
2 Do one of the following:
• Select Modify > Table > Merge Cells. • In the expanded HTML Property inspector (Window > Properties), click Merge Cells
.
Note: If you don’t see the button, click the expander arrow in the lower-right corner of the Property inspector so that you see all the options. The contents of the individual cells are placed in the resulting merged cell. The properties of the first cell selected are applied to the merged cell.
Split a cell 1 Click in the cell and do one of the following:
• Select Modify > Table > Split Cell. • In the expanded HTML Property inspector (Window > Properties), click Split Cell
.
Note: If you don’t see the button, click the expander arrow in the lower-right corner of the Property inspector so that you see all the options. 2 In the Split Cell dialog box, specify how to split the cell: Split Cell Into Specifies whether to split the cell into rows or columns. Number Of Rows/Number Of Columns Specifies how many rows or columns to split the cell into.
Increase or decrease the number of rows or columns spanned by a cell ❖ Do one of the following:
• Select Modify > Table > Increase Row Span, or Modify > Table > Increase Column Span. • Select Modify > Table > Decrease Row Span, or Modify > Table > Decrease Column Span.
Copy, paste, and delete cells You can copy, paste, or delete a single table cell or multiple cells at once, preserving the cells’ formatting. You can paste cells at the insertion point or in place of a selection in an existing table. To paste multiple table cells, the contents of the Clipboard must be compatible with the structure of the table or the selection in the table in which the cells will be pasted.
Cut or copy table cells 1 Select one or more cells in a contiguous line and in the shape of a rectangle.
Last updated 3/28/2012
180
USING DREAMWEAVER Laying out pages with HTML
In the following illustration, the selection is a rectangle of cells, so the cells can be cut or copied.
In the following illustration, the selection is not a rectangle, so the cells can’t be cut or copied.
2 Select Edit > Cut or Edit > Copy.
Note: If you selected an entire row or column and you select Edit > Cut, the entire row or column is removed from the table (not just the contents of the cells).
Paste table cells 1 Select where you want to paste the cells:
• To replace existing cells with the cells you are pasting, select a set of existing cells with the same layout as the cells on the clipboard. (For example, if you’ve copied or cut a 3 x 2 block of cells, you can select another 3 x 2 block of cells to replace by pasting.)
• To paste a full row of cells above a particular cell, click in that cell. • To paste a full column of cells to the left of a particular cell, click in that cell. Note: If you have less than a full row or column of cells in the clipboard, and you click in a cell and paste the cells from the clipboard, the cell you clicked in and its neighbors may (depending on its location in the table) be replaced with the cells you are pasting.
• To create a new table with the pasted cells, place the insertion point outside of the table. 2 Select Edit > Paste.
If you are pasting entire rows or columns into an existing table, the rows or columns are added to the table. If you are pasting an individual cell, the contents of the selected cell are replaced. If you are pasting outside a table, the rows, columns, or cells are used to define a new table.
Remove cell content but leave the cells intact 1 Select one or more cells.
Note: Make sure the selection does not consist entirely of complete rows or columns. 2 Select Edit > Clear or press Delete.
Note: If only complete rows or columns are selected when you select Edit > Clear or press Delete, the entire rows or columns—not just their contents—are removed from the table.
Last updated 3/28/2012
181
USING DREAMWEAVER Laying out pages with HTML
Delete rows or columns that contain merged cells 1 Select the row or column. 2 Select Modify > Table > Delete Row, or Modify > Table > Delete Column.
Nest tables A nested table is a table inside a cell of another table. You can format a nested table as you would any other table; however, its width is limited by the width of the cell in which it appears. 1 Click in a cell of the existing table. 2 Select Insert > Table, set the Insert Table options, and click OK.
Sort tables You can sort the rows of a table based on the contents of a single column. You can also perform a more complicated table sort based on the contents of two columns. You cannot sort tables that contain colspan or rowspan attributes—that is, tables that contain merged cells. 1 Select the table or click in any cell. 2 Select Commands > Sort Table, set the options in the dialog box, and click OK. Sort By Determines which column’s values will be used to sort the table’s rows. Order Determines whether to sort the column alphabetically or numerically, and whether to sort it in ascending order
(A to Z, lower numbers to higher numbers) or descending order. When the contents of a column are numbers, select Numerically. An alphabetic sort applied to a list of one- and twodigit numbers results in the numbers being sorted as if they were words (resulting in ordering such as 1, 10, 2, 20, 3, 30) rather than being sorted as numbers (resulting in ordering such as 1, 2, 3, 10, 20, 30). Then By/Order Determines the sorting order for a secondary sort on a different column. Specify the secondary-sort
column in the Then By pop-up menu, and the secondary sort order in the Order pop-up menus. Sort Includes The First Row Specifies that the first row of the table should be included in the sort. If the first row is a
heading that should not be moved, do not select this option. Sort Header Rows Specifies to sort all the rows in the table’s thead section (if any) using the same criteria as the body
rows. (Note that thead rows remain in the thead section and still appear at the top of the table even after sorting.) For information about the thead tag, see the Reference panel (select Help > Reference). Sort Footer Rows Specifies to sort all the rows in the table’s tfoot section (if any) using the same criteria as the body
rows. (Note that tfoot rows remain in the tfoot section and still appear at the bottom of the table even after sorting.) For information about the tfoot tag, see the Reference panel (select Help > Reference). Keep All Row Colors The Same After The Sort Has Been Completed Specifies that table row attributes (such as color) should remain associated with the same content after the sort. If your table rows are formatted with two alternating colors, do not select this option to ensure that the sorted table still has alternating-colored rows. If the row attributes are specific to the content of each row, then select this option to ensure that those attributes remain associated with the correct rows in the sorted table.
Last updated 3/28/2012
182
USING DREAMWEAVER Laying out pages with HTML
Using Frames How frames and framesets work A frame is a region in a browser window that can display an HTML document independent of what’s being displayed in the rest of the browser window. Frames provide a way to divide a browser window into multiple regions, each of which can display a different HTML document. In the most common use of frames, one frame displays a document containing navigation controls, while another frame displays a document with content A frameset is an HTML file that defines the layout and properties of a set of frames, including the number of frames, the size and placement of the frames, and the URL of the page that initially appears in each frame. The frameset file itself doesn’t contain HTML content that displays in a browser, except in the noframes section; the frameset file simply provides information to the browser about how a set of frames should look and what documents should appear in them. To view a set of frames in a browser, enter the URL of the frameset file; the browser then opens the relevant documents to display in the frames. The frameset file for a site is often named index.html, so that it displays by default if a visitor doesn’t specify a filename. The following example shows a frame layout consisting of three frames: one narrow frame on the side that contains a navigation bar, one frame that runs along the top, containing the logo and title of the website, and one large frame that takes up the rest of the page and contains the main content. Each of these frames displays a separate HTML document.
In this example, the document displayed in the top frame never changes as the visitor navigates the site. The side frame navigation bar contains links; clicking one of these links changes the content of the main content frame, but the contents of the side frame itself remain static. The main content frame on the right displays the appropriate document for the link the visitor clicks on the left. A frame is not a file; it’s easy to think of the document that currently appears in a frame as an integral part of the frame, but the document isn’t actually part of the frame. The frame is a container that holds the document.
Last updated 3/28/2012
183
USING DREAMWEAVER Laying out pages with HTML
Note: A “page” refers either to a single HTML document or to the entire contents of a browser window at a given moment, even if several HTML documents appear at once. The phrase “a page that uses frames,” for example, usually refers to a set of frames and the documents that initially appear in those frames. A site that appears in a browser as a single page comprising three frames actually consists of at least four HTML documents: the frameset file, plus the three documents containing the content that initially appears in the frames. When you design a page using framesets in Dreamweaver, you must save each of these four files in order for the page to work properly in the browser. For more comprehensive information about Frames, consult Thierry Koblentz’s website at www.tjkdesign.com/articles/frames/.
Deciding whether to use frames Adobe discourages the use of frames for web page layout. Some of the disadvantages of using frames include:
• Precise graphical alignment of elements in different frames can be difficult. • Testing the navigation can be time-consuming. • The URLs of the individual framed pages don’t appear in browsers, so it can be difficult for a visitor to bookmark a specific page (unless you provide server code that enables them to load a framed version of a particular page). For a full treatment of why you should not use frames, see Gary White’s explanation at http://apptools.com/rants/framesevil.php. The most common use of frames, if you do decide to use them, is for navigation. A set of frames often includes one frame containing a navigation bar and another frame to display the main content pages. Using frames in this way has a couple of advantages:
• A visitor’s browser doesn’t need to reload the navigation-related graphics for every page. • Each frame has its own scroll bar (if the content is too large to fit in a window), so a visitor can scroll the frames independently. For example, a visitor who scrolls to the bottom of a long page of content in a frame doesn’t need to scroll back up to the top to use the navigation bar if the navigation bar is in a different frame.
Last updated 3/28/2012
184
USING DREAMWEAVER Laying out pages with HTML
In many cases, you can create a web page without frames that accomplishes the same goals as a set of frames. For example, if you want a navigation bar to appear on the left side of your page, you can either replace your page with a set of frames, or just include the navigation bar on every page in your site. (Dreamweaver helps you create multiple pages that use the same layout.) The following example shows a page design with a framelike layout that doesn’t use frames.
Poorly designed sites use frames unnecessarily, such as a frameset that reloads the contents of the navigation frames every time the visitor clicks a navigation button. When frames are used well (for example, to keep navigation controls static in one frame while allowing the contents of another frame to change), they can be very useful for a site. Not all browsers provide good frame support, and frames may be difficult for visitors with disabilities to navigate, so if you do use frames, always provide a noframes section in your frameset, for visitors who can’t view them. You might also provide an explicit link to a frameless version of the site. For more comprehensive information about Frames, consult Thierry Koblentz’s website at www.tjkdesign.com/articles/frames/.
Nested framesets A frameset inside another frameset is called a nested frameset. A single frameset file can contain multiple nested framesets. Most web pages that use frames are actually using nested frames, and most of the predefined framesets in Dreamweaver also use nesting. Any set of frames in which there are different numbers of frames in different rows or columns requires a nested frameset. For example, the most common frame layout has one frame in the top row (where the company’s logo appears) and two frames in the bottom row (a navigation frame and a content frame). This layout requires a nested frameset: a tworow frameset, with a two-column frameset nested in the second row.
Last updated 3/28/2012
185
USING DREAMWEAVER Laying out pages with HTML
A
B
A. Main frameset B. Menu frame and content frame are nested within the main frameset.
Dreamweaver takes care of nesting framesets as needed; if you use the frame-splitting tools in Dreamweaver, you don’t need to worry about the details of which frames are nested and which are not. There are two ways to nest framesets in HTML: the inner frameset can be defined either in the same file as the outer frameset, or in a separate file of its own. Each predefined frameset in Dreamweaver defines all of its framesets in the same file. Both kinds of nesting produce the same visual results; it’s not easy to tell, without looking at the code, which kind of nesting is being used. The most likely situation in which an external frameset file would be used in Dreamweaver is when you use the Open in Frame command to open a frameset file inside a frame; doing this may result in problems with setting targets for links. It’s generally simplest to keep all framesets defined in a single file.
Work with framesets in the Document window Dreamweaver enables you to view and edit all of the documents associated with a set of frames in one Document window. This approach enables you to see approximately how the framed pages will appear in a browser as you edit them. However, some aspects of this approach can be confusing until you get used to them. In particular, each frame displays a separate HTML document. Even if the documents are empty, you must save them all before you can preview them (because the frameset can be accurately previewed only if it contains the URL of a document to display in each frame). To ensure that your frameset appears correctly in browsers, follow these general steps: 1 Create your frameset and specify a document to appear in each frame. 2 Save every file that’s going to appear in a frame. Remember that each frame displays a separate HTML document,
and you must save each document, along with the frameset file. 3 Set the properties for each frame and for the frameset (including naming each frame, setting scrolling and non-
scrolling options). 4 Set the Target property in the Property inspector for all your links so that the linked content appears in the correct area.
Create frames and framesets There are two ways to create a frameset in Dreamweaver: You can select from several predefined framesets or you can design it yourself.
Last updated 3/28/2012
186
USING DREAMWEAVER Laying out pages with HTML
Choosing a predefined frameset sets up all the framesets and frames needed to create the layout and is the easiest way to create a frames-based layout quickly. You can insert a predefined frameset only in the Document window’s Design view. You can also design your own frameset in Dreamweaver by adding “splitters” to the Document window. Before creating a frameset or working with frames, make the frame borders visible in the Document window’s Design view by selecting View >Visual Aids > Frame Borders.
More Help topics “Dreamweaver and accessibility” on page 652
Create a predefined frameset and display an existing document in a frame 1 Place the insertion point in a document and do one of the following:
•
Choose Insert > HTML > Frames and select a predefined frameset.
• In the Layout category of the Insert panel, click the drop-down arrow on the Frames button and select a predefined frameset. The frameset icons provide a visual representation of each frameset as applied to the current document. The blue area of a frameset icon represents the current document, and the white areas represent frames that will display other documents. 2 If you have set up Dreamweaver to prompt you for frame accessibility attributes, select a frame from the pop-up
menu, enter a name for the frame, and click OK. (For visitors who use screen readers, the screen reader will read this name when it encounters the frame in a page.) Note: If you click OK without entering a new name, Dreamweaver gives the frame a name that corresponds to its position (left frame, right frame, and so on) in the frameset. Note: If you press Cancel, the frameset appears in the document, but Dreamweaver does not associate accessibility tags or attributes with it. Select Window > Frames to view a diagram of the frames you are naming.
Create an empty predefined frameset 1 Select File > New. 2 In the New Document dialog box, select the Page from Sample category. 3 Select the Frameset folder in the Sample Folder column. 4 Select a frameset from the Sample Page column and click Create. 5 If you have activated the frame accessibility attributes in Preferences, the Frame Tag Accessibility Attributes dialog
box appears; complete the dialog box for each frame and click OK. Note: If you press Cancel, the frameset appears in the document, but Dreamweaver does not associate accessibility tags or attributes with it.
Create a frameset ❖ Select Modify > Frameset, then select a splitting item (such as Split Frame Left or Split Frame Right) from the
submenu. Dreamweaver splits the window into frames. If you had an existing document open, it appears in one of the frames.
Last updated 3/28/2012
187
USING DREAMWEAVER Laying out pages with HTML
Split a frame into smaller frames • To split the frame where the insertion point is, select a splitting item from the Modify > Frameset submenu. • To split a frame or set of frames vertically or horizontally, drag a frame border from the edge into the middle of the Design view.
• To split a frame using a frame border that isn’t at the edge of the Design view, Alt-drag (Windows) or Option-drag (Macintosh) a frame border.
• To divide a frame into four frames, drag a frame border from one of the corners of the Design view into the middle of a frame. To create three frames, start with two frames, then split one of them. It’s not easy to merge two adjacent frames without editing the frameset code, so changing four frames into three frames is harder than changing two frames into three frames.
Delete a frame ❖ Drag a frame border off the page or to a border of the parent frame.
If there’s unsaved content in a document in a frame that’s being removed, Dreamweaver prompts you to save the document. Note: You can’t remove a frameset entirely by dragging borders. To remove a frameset, close the Document window that displays it. If the frameset file has been saved, delete the file.
Resize a frame • To set approximate sizes for frames, drag frame borders in the Document window’s Design view. • To specify exact sizes, and to specify how much space the browser allocates to a row or column of frames when the browser window size doesn’t allow the frames to display at full size, use the Property inspector.
Select frames and framesets To make changes to the properties of a frame or frameset, begin by selecting the frame or frameset you want to change. You can select a frame or frameset either in the Document window or by using the Frames panel.
Last updated 3/28/2012
188
USING DREAMWEAVER Laying out pages with HTML
The Frames panel provides a visual representation of the frames within a frameset. It shows the hierarchy of the frameset structure in a way that may not be apparent in the Document window. In the Frames panel, a very thick border surrounds each frameset; each frame is surrounded by a thin gray line and is identified by a frame name.
In the Document window’s Design view, when a frame is selected, its borders are outlined with a dotted line; when a frameset is selected, all the borders of the frames within the frameset are outlined with a light dotted line. Note: Placing the insertion point in a document that’s displayed in a frame is not the same as selecting a frame. There are various operations (such as setting frame properties) for which you must select a frame.
Select a frame or frameset in the Frames panel 1 Select Window > Frames. 2 In the Frames panel:
• To select a frame, click the frame. (A selection outline appears around the frame in both the Frames panel and the Document window’s Design view.)
• To select a frameset, click the border that surrounds the frameset.
Select a frame or frameset in the Document window • To select a frame, Shift-Alt-click (Windows) or Shift-Option-click (Macintosh) inside a frame in Design view. • To select a frameset, click one of the frameset’s internal frame borders in Design view. (Frame borders must be visible to do this; select View >Visual Aids > Frame Borders to make frame borders visible if they aren’t.) Note: It’s generally easier to select framesets in the Frames panel than in the Document window. For more information, see the above topics.
Last updated 3/28/2012
189
USING DREAMWEAVER Laying out pages with HTML
Select a different frame or frameset • To select the next or previous frame or frameset at the same hierarchical level as the current selection, press Alt+Left Arrow or Alt+Right Arrow (Windows), or Command+Left Arrow or Command+Right Arrow (Macintosh). Using these keys, you can cycle through frames and framesets in the order in which they’re defined in the frameset file.
• To select the parent frameset (the frameset that contains the current selection), press Alt+Up Arrow (Windows) or Command+Up Arrow (Macintosh).
• To select the first child frame or frameset of the currently selected frameset (that is, first in the order in which they’re defined in the frameset file), press Alt+Down Arrow (Windows) or Command+Down Arrow (Macintosh).
Open a document in a frame You can specify the initial content of a frame by either inserting new content into an empty document in a frame, or opening an existing document in a frame. 1 Place the insertion point in a frame. 2 Select File > Open in Frame. 3 Select a document to open in the frame, and click OK (Windows) or Choose (Macintosh). 4 (Optional) To make this document the default document to display in the frame when the frameset is opened in a
browser, save the frameset.
Save frame and frameset files Before you can preview a frameset in a browser, you must save the frameset file and all of the documents that will display in the frames. You can save each frameset file and framed document individually, or you can save the frameset file and all documents appearing in frames at once. Note: When you use visual tools in Dreamweaver to create a set of frames, each new document that appears in a frame is given a default filename. For example, the first frameset file is named UntitledFrameset-1, while the first document in a frame is named UntitledFrame-1.
Save a frameset file ❖ Select the frameset in the Frames panel or the Document window.
• To save the frameset file, select File > Save Frameset. • To save the frameset file as a new file, select File > Save Frameset As. Note: If the frameset file has not previously been saved, these two commands are equivalent.
Save a document that appears in a frame ❖ Click in the frame, then select File > Save Frame or File > Save Frame As.
Save all files associated with a set of frames ❖ Select File > Save All Frames.
This saves all open documents in the frameset, including the frameset file and all framed documents. If the frameset file has not yet been saved, a heavy border appears around the frameset (or the unsaved frame) in the Design view, and you can select a filename.
Last updated 3/28/2012
190
USING DREAMWEAVER Laying out pages with HTML
Note: If you used File > Open in Frame to open a document in a frame, then when you save the frameset, the document you opened in the frame becomes the default document to be displayed in that frame. If you don’t want that document to be the default, don’t save the frameset file.
View and set frame properties and attributes Use the Property inspector to view and set most frame properties, including borders, margins, and whether scroll bars appear in frames. Setting a frame property overrides the setting for that property in a frameset. You may also want to set some frame attributes, such as the title attribute (which is not the same as the name attribute), to improve accessibility. You can enable the accessibility authoring option for frames to set attributes when you create frames, or you can set attributes after inserting a frame. To edit accessibility attributes for a frame, use the Tag inspector to edit the HTML code directly.
More Help topics “Dreamweaver and accessibility” on page 652
View or set frame properties 1 Select a frame by doing one of the following:
• Alt-click (Windows) or Shift-Option-click (Macintosh) a frame in the Document window’s Design view. • Click a frame in the Frames panel (Window > Frames). 2 In the Property inspector (Window > Properties), click the expander arrow in the lower-right corner to see all of
the frame properties. 3 Set the frame Property inspector options. Frame Name The name used by a link’s target attribute or by a script to refer to the frame. A frame name must be a
single word; underscores (_) are allowed, but hyphens (-), periods (.), and spaces are not. A frame name must start with a letter (as opposed to a numeral). Frame names are case-sensitive. Don’t use terms that are reserved words in JavaScript (such as top or navigator) as frame names. To make a link change the contents of another frame, you must name the target frame. To make it easier to create cross-frame links later, name each of your frames when you create it. Src Specifies the source document to display in the frame. Click the folder icon to browse to and select a file. Scroll Specifies whether scroll bars appear in the frame. Setting this option to Default doesn’t set a value for the
corresponding attribute, allowing each browser to use its default value. Most browsers default to Auto, meaning that scroll bars appear only when there is not enough room in a browser window to display the full contents of the current frame. No Resize Prevents visitors from dragging the frame borders to resize the frame in a browser.
Note: You can always resize frames in Dreamweaver; this option applies only to visitors viewing the frames in a browser. Borders Shows or hides the borders of the current frame when it’s viewed in a browser. Selecting a Borders option for a frame overrides the frameset’s border settings.
Border options are Yes (show borders), No (hide borders), and Default; most browsers default to showing borders, unless the parent frameset has Borders set to No. A border is hidden only when all frames that share the border have Borders set to No, or when the parent frameset’s Borders property is set to No and the frames sharing the border have Borders set to Default.
Last updated 3/28/2012
191
USING DREAMWEAVER Laying out pages with HTML
Border Color Sets a border color for all of the frame’s borders. This color applies to all borders that touch the frame, and overrides the specified border color of the frameset. Margin Width Sets the width in pixels of the left and right margins (the space between the frame borders and the
content). Margin Height Sets the height in pixels of the top and bottom margins (the space between the frame borders and the
content). Note: Setting the margin width and height for a frame is not the same as setting margins in the Modify > Page Properties dialog box. To change the background color of a frame, set the background color of the document in the frame in page properties.
Set accessibility values for a frame 1 In the Frames panel (Window > Frames), select a frame by placing the insertion point in one of the frames. 2 Select Modify > Edit Tag . 3 Select Style Sheet/Accessibility from the category list on the left, enter values, and click OK.
Edit accessibility values for a frame 1 Display Code view or Code and Design views for your document, if you’re currently in Design view. 2 In the Frames panel (Window > Frames), select a frame by placing the insertion point in one of the frames.
Dreamweaver highlights the frame tag in the code. 3 Right-click (Windows) or Control-click (Macintosh) in the code, and then select Edit Tag. 4 In the tag editor, make your changes and click OK.
Change the background color of a document in a frame 1 Place the insertion point in the frame. 2 Select Modify > Page Properties. 3 In the Page Properties dialog box, click the Background color menu, and select a color.
View and set frameset properties Use the Property inspector to view and set most frameset properties, including the frameset title, borders, and frame sizes.
Set a title for a frameset document 1 Select a frameset by doing one of the following:
• Click a border between two frames in the frameset in the Document window’s Design view. • Click the border that surrounds a frameset in the Frames panel (Window > Frames). 2 In the Title box of the Document toolbar, type a name for the frameset document.
When a visitor views the frameset in a browser, the title appears in the browser’s title bar.
Last updated 3/28/2012
192
USING DREAMWEAVER Laying out pages with HTML
View or set frameset properties 1 Select a frameset by doing one of the following:
• Click a border between two frames in the frameset in the Document window’s Design view. • Click the border that surrounds a frameset in the Frames panel (Window > Frames). 2 In the Property inspector (Window > Properties), click the expander arrow in the lower-right corner and set the
frameset options. Borders Determines whether borders should appear around frames when the document is viewed in a browser. To display borders, select Yes; to prevent the browser from displaying borders, select No. To allow the browser to determine how borders are displayed, select Default. Border Width Specifies a width for all the borders in the frameset. Border Color Sets a color for the borders. Use the color picker to select a color, or type the hexadecimal value for a
color. RowCol Selection Sets frame sizes for rows and columns of the selected frameset, click a tab on the left side or top of the RowCol Selection area; then enter a height or width in the Value text box.
3 To specify how much space the browser allocates to each frame, select from the following choices in the Units menu: Pixels Sets the size of the selected column or row to an absolute value. Choose this option for a frame that should always be the same size, such as a navigation bar. Frames with sizes specified in pixels are allocated space before frames with sizes specified as percent or relative. The most common approach to frame sizes is to set a left-side frame to a fixed pixel width and to set a right-size frame to relative, which enables the right frame to stretch to take up all the remaining space after the pixel width is allocated.
Note: If all of your widths are specified in pixels, and a visitor views the frameset in a browser that’s too wide or too narrow for the width you specified, then the frames stretch or shrink proportionately to fill the available space. The same applies to heights specified in pixels. Thus, it’s generally a good idea to specify at least one width and height as relative. Percent Specifies that the selected column or row should be a percentage of the total width or height of its frameset. Frames with units set to Percent are allocated space after frames with units set to Pixels, but before frames with units set to Relative. Relative Specifies that the selected column or row be allocated the rest of the available space after Pixels and Percent
frames have had space allocated; that remaining space is divided proportionally among the frames with sizes set to Relative. Note: When you select Relative from the Units menu, any number you’ve entered in the Value field disappears; if you want to specify a number, you must re-enter it. If there’s only one row or column set to Relative, though, there’s no need to enter a number, since that row or column receives all the remaining space after the other rows and columns have space allocated. To be certain of full cross-browser compatibility, you can enter 1 in the Value field; that’s equivalent to entering no value.
Last updated 3/28/2012
193
USING DREAMWEAVER Laying out pages with HTML
Control frame content with links To use a link in one frame to open a document in another frame, you must set a target for the link. The target attribute of a link specifies the frame or window in which the linked content opens. For example, if your navigation bar is in the left frame, and you want the linked material to appear in the main content frame on the right, you must specify the name of the main content frame as the target for each of the navigation bar links. When a visitor clicks a navigation link, the specified content opens in the main frame. 1 In Design view, select text or an object. 2 In the Link box in the Property inspector (Window > Properties), do one of the following:
• Click the folder icon and select the file to link to. • Drag the Point to File icon to the Files panel and select the file to link to. 3 In the Target menu in the Property inspector, select the frame or window in which the linked document should
appear:
•
_blank opens the linked document in a new browser window, leaving the current window untouched.
•
_parent opens the linked document in the parent frameset of the frame the link appears in, replacing the entire
frameset.
•
_self opens the link in the current frame, replacing the content in that frame.
•
_top opens the linked document in the current browser window, replacing all frames.
Frame names also appear in this menu. Select a named frame to open the linked document in that frame. Note: Frame names appear only when you’re editing a document within a frameset. When you edit a document in its own Document window, frame names do not appear in the Target pop-up menu. If you’re editing a document outside of the frameset, you can type the target frame’s name in the Target text box. If you’re linking to a page outside of your site, always use target="_top" or target="_blank" to ensure that the page doesn’t appear to be part of your site.
Provide content for browsers without frame support Dreamweaver lets you specify content to display in text-based browsers and in older graphical browsers that do not support frames. This content is stored in the frameset file, wrapped in a noframes tag. When a browser that doesn’t support frames loads the frameset file, the browser displays only the content enclosed by the noframes tag. Note: Content in the noframes area should be more than just a note saying “You should upgrade to a browser that can handle frames.” Some site visitors use systems that don’t allow them to view frames. 1 Select Modify > Frameset > Edit NoFrames Content.
Dreamweaver clears the Design view, and the words “NoFrames Content” appear at the top of the Design view. 2 Do one of the following:
• In the Document window, type or insert the content just as you would for an ordinary document. • Select Window > Code Inspector, place the insertion point between the body tags that appear inside the noframes tags, then type the HTML code for the content. 3 Select Modify > Frameset > Edit NoFrames Content again to return to the normal view of the frameset document.
Last updated 3/28/2012
194
USING DREAMWEAVER Laying out pages with HTML
Using JavaScript behaviors with frames There are several JavaScript behaviors and navigation-related commands that are particularly appropriate for use with frames: Set Text Of Frame Replaces the content and formatting of a given frame with the content you specify. The content can
include any valid HTML. Use this action to dynamically display information in a frame. Go To URL Opens a new page in the current window or in the specified frame. This action is particularly useful for changing the contents of two or more frames with one click. Insert Jump Menu Sets up a menu list of links that open files in a browser window when clicked. You can also target a
particular window or frame in which the document opens. For more information, see “Adding JavaScript behaviors” on page 328.
More Help topics “Apply the Set Text Of Frame behavior” on page 337 “Apply the Go To URL behavior” on page 334 “Apply the Set Nav Bar Image behavior” on page 337 “Apply the Jump Menu behavior” on page 335
Last updated 3/28/2012
195
Chapter 8: Adding content to pages Use the Insert panel The Insert panel contains buttons for creating and inserting objects such as tables and images. The buttons are organized into categories.
More Help topics “Insert panel overview” on page 13 “Edit tags with Tag editors” on page 294 “Select and view elements in the Document window” on page 202
Hide or show the Insert panel ❖ Select Window > Insert.
Note: If you are working with certain types of files, such as XML, JavaScript, Java, and CSS, the Insert panel and the Design view option are dimmed because you cannot insert items into these code files.
Show the buttons in a particular category ❖ Select the category name from the Category pop-up menu. For example, to show buttons for the Layout category,
select Layout.
Display the pop-up menu for a button ❖ Click the down arrow beside the button’s icon.
Last updated 3/28/2012
196
USING DREAMWEAVER Adding content to pages
Insert an object 1 Select the appropriate category from the Category pop-up menu of the Insert panel. 2 Do one of the following:
• Click an object button or drag the button’s icon into the Document window. • Click the arrow on a button, then select an option from the menu. Depending on the object, a corresponding object-insertion dialog box may appear, prompting you to browse to a file or specify parameters for an object. Or, Dreamweaver may insert code into the document, or open a tag editor or a panel for you to specify information before the code is inserted. For some objects, no dialog box appears if you insert the object in Design view, but a tag editor appears if you insert the object in Code view. For a few objects, inserting the object in Design view causes Dreamweaver to switch to Code view before inserting the object. Note: Some objects, such as named anchors, are not visible when the page is viewed in a browser window. You can display icons in Design view that mark the locations of such invisible objects.
Bypass the object-insertion dialog box and insert an empty placeholder object ❖ Control-click (Windows) or Option-click (Macintosh) the button for the object.
For example, to insert a placeholder for an image without specifying an image file, Control-click or Option-click the Image button. Note: This procedure does not bypass all object-insertion dialog boxes. Many objects, including AP elements and framesets, do not insert placeholders or default-valued objects.
Modify preferences for the Insert panel 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 In the General category of the Preferences dialog box, deselect Show Dialog When Inserting Objects to suppress
dialog boxes when you insert objects such as images, tables, scripts, and head elements or by holding down the Control key (Windows) or the Option key (Macintosh) while creating the object. When you insert an object with this option off, the object is given default attribute values. Use the Property inspector to change object properties after inserting the object.
Add, delete, or manage items in the Favorites category of the Insert panel 1 Select any category in the Insert panel. 2 Right-click (Windows) or Control-click (Macintosh) in the area where the buttons appear, and then select
Customize Favorites. 3 In the Cutomize Favorite Objects dialog box, make changes as necessary, and click OK.
• To add an object, select an object in the Available Objects pane on the left, and then click the arrow between the two panes or double-click the object in the Available Objects pane. Note: You can add one object at a time. You cannot select a category name, such as Common, to add an entire category to your favorites list.
Last updated 3/28/2012
197
USING DREAMWEAVER Adding content to pages
• To delete an object or separator, select an object in the Favorite Objects pane on the right, and then click the Remove Selected Object in Favorite Objects List button above the pane.
• To move an object, select an object in the Favorite Objects pane on the right, and then click the Up or Down arrow button above the pane.
• To add a separator below an object, select an object in the Favorite Objects pane on the right, and then click the Add Separator button below the pane. 4 If you’re not in the Favorites category of the Insert panel, select that category to see your changes.
Insert objects using buttons in the Favorites category ❖ Select the Favorites category from the Category pop-up menu of the Insert panel, and then click the button for any
Favorites object that you added.
Display the Insert panel as a horizontal Insert bar Unlike other panels in Dreamweaver, you can drag the Insert panel out of its default dock position and drop it into a horizontal position at the top of the Document window. When you do so, it changes from a panel to a toolbar (though you cannot hide and display it in the same way as other toolbars). 1 Click the Insert panel’s tab and drag it to the top of the Document window.
2 When you see a horizontal blue line across the top of the Document window, drop the Insert panel into position.
Note: The horizontal Insert bar is also a default part of the Classic workspace. To switch to the Classic workspace, select Classic from the workspace switcher in the Application bar.
Last updated 3/28/2012
198
USING DREAMWEAVER Adding content to pages
Return the horizontal Insert bar to a panel group 1 Click the horizontal Insert bar’s gripper (on the left side of the Insert bar) and drag the bar to the place where your
panels are docked. 2 Position the Insert panel and drop it. A blue line indicates where you can drop the panel.
Show horizontal Insert bar categories as tabs ❖ Click the arrow beside the category name on the left end of the horizontal Insert bar, and then select Show as Tabs.
Show horizontal Insert bar categories as a menu ❖ Right-click (Windows) or Control-click (Macintosh) a category tab in the horizontal Insert bar, and then select
Show as Menus.
Set page properties For each page you create in Dreamweaver, you can specify layout and formatting properties using the Page Properties dialog box (Modify > Page Properties). The Page Properties dialog box lets you specify the default font family and font size, background color, margins, link styles, and many other aspects of page design. You can assign new page properties for each new page you create, and modify those for existing pages. Changes you make in the Page Properties dialog box apply to the entire page. Dreamweaver gives you two methods for modifying page properties: CSS or HTML. Adobe recommends using CSS to set backgrounds and modify page properties. Note: The page properties you choose apply only to the active document. If a page uses an external CSS style sheet, Dreamweaver does not overwrite the tags set in the style sheet, as this affects all other pages using that style sheet.
Set CSS page font, background color, and background image properties Use the Page Properties dialog box to specify several basic page layout options for your web pages, including the font, background color, and background image. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Select the Appearance (CSS) category and set the options. Page Font Specifies the default font family to use in your web pages. Dreamweaver uses the font family you specify unless another font is specifically set for a text element. Size Specifies the default font size to use in your web pages. Dreamweaver uses the font size you specify unless another font size is specifically set for a text element. Text Color Specifies the default color to render fonts with. Background Color Sets a background color for your page. Click the Background color box and select a color from the
Color Picker. Background Image Sets a background image. Click the Browse button, then browse to and select the image. Alternatively, enter the path to the background image in the Background Image box.
Dreamweaver tiles (repeats) the background image if it does not fill the entire window, just as browsers do. (To prevent the background image from tiling, use Cascading Style Sheets to disable image tiling.)
Last updated 3/28/2012
199
USING DREAMWEAVER Adding content to pages
Repeat Specifies how the background image will be displayed on the page:
• Select the No-repeat option to display the background image only once. • Select the Repeat option to repeat, or tile, the image both horizontally and vertically. • Select the Repeat-x option to tile the image horizontally. • Select the Repeat-y option to tile the image vertically. Left Margin and Right Margin Specify the size of the left and right page margins. Top Margin and Bottom Margin Specify the size of the top and bottom page margins.
Set HTML page properties Setting properties in this category of the Page Properties dialog box results in HTML rather than CSS formatting of your page. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Select the Appearance (HTML) category and set the options. Background Image Sets a background image. Click the Browse button, then browse to and select the image. Alternatively, enter the path to the background image in the Background Image box.
Dreamweaver tiles (repeats) the background image if it does not fill the entire window, just as browsers do. (To prevent the background image from tiling, use Cascading Style Sheets to disable image tiling.) Background Sets a background color for your page. Click the Background color box and select a color from the Color
Picker. Text Specifies the default color to render fonts with. Link Specifies the color to apply to link text. Visited Links Specifies the color to apply to visited links. Active Links Specifies the color to apply when a mouse (or pointer) clicks on a link Left Margin and Right Margin Specify the size of the left and right page margins. Top Margin and Bottom Margin Specify the size of the top and bottom page margins.
Set CSS link properties for an entire page You can specify fonts, font sizes, colors, and other items for your links. By default, Dreamweaver creates CSS rules for your links and applies them to all links you use on the page. (The rules are embedded in the head section of the page.) Note: If you want to customize individual links on a page, you need to create individual CSS rules, and then apply them to the links separately. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Choose the Links (CSS) category and set the options. Link Font Specifies the default font family to use for link text. By default, Dreamweaver uses the font family specified for the entire page unless you specify another font. Size Specifies the default font size to use for link text. Link Color Specifies the color to apply to link text.
Last updated 3/28/2012
200
USING DREAMWEAVER Adding content to pages
Visited Links Specifies the color to apply to visited links. Rollover Links Specifies the color to apply when a mouse (or pointer) hovers over a link. Active Links Specifies the color to apply when a mouse (or pointer) clicks on a link Underline Style Specifies the underline style to apply to links. If your page already has an underline link style defined
(through an external CSS style sheet for example), the Underline Style menu defaults to a “don’t change” option. This option alerts you to a link style that has been defined. If you modify the underline link style using the Page Properties dialog box, Dreamweaver will change the previous link definition.
Set CSS heading properties for an entire page You can specify fonts, font sizes, and colors for your page headings. By default, Dreamweaver creates CSS rules for your headings and applies them to all headings you use on the page. (The rules are embedded in the head section of the page.) Headings are available for selection in HTML Property inspector. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Choose the Headings (CSS) category and set the options. Heading Font Specifies the default font family to use for headings. Dreamweaver will use the font family you specify unless another font is specifically set for a text element. Heading 1 through Heading 6 Specify the font size and color to use for up to six levels of heading tags.
Set title and encoding properties for a page The Title/Encoding Page Properties options let you specify the document encoding type that is specific to the language used to author your web pages as well as specify which Unicode Normalization Form to use with that encoding type. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Choose the Title/Encoding category and set the options. Title Specifies the page title that appears in the title bar of the Document window and most browser windows. Document Type (DTD) Specifies a document type definition. For example, you can make an HTML document XHTML-compliant by selecting XHTML 1.0 Transitional or XHTML 1.0 Strict from the pop-up menu. Encoding Specifies the encoding used for characters in the document.
If you select Unicode (UTF-8) as the document encoding, entity encoding is not necessary because UTF-8 can safely represent all characters. If you select another document encoding, entity encoding may be necessary to represent certain characters. For more information on character entities, see www.w3.org/TR/REC-html40/sgml/entities.html. Reload Converts the existing document, or reopens it using the new encoding. Unicode Normalization Form Enabled only if you select UTF-8 as a document encoding. There are four Unicode
Normalization Forms. The most important is Normalization Form C because it’s the most common form used in the Character Model for the World Wide Web. Adobe provides the other three Unicode Normalization Forms for completeness.
Last updated 3/28/2012
201
USING DREAMWEAVER Adding content to pages
In Unicode, some characters are visually similar but can be stored within the document in different ways. For example, “ë” (e-umlaut) can be represented as a single character, “e-umlaut,” or as two characters, “regular Latin e” + “combining umlaut.” A Unicode combining character is one that gets used with the previous character, so the umlaut would appear above the “Latin e.” Both forms result in the same visual typography, but what is saved in the file is different for each form. Normalization is the process of making sure all characters that can be saved in different forms are all saved using the same from. That is, all “ë” characters in a document are saved as single “e-umlaut” or as “e” + “combining umlaut,” and not as both forms in one document. For more information on Unicode Normalization and the specific forms that can be used, see the Unicode website at www.unicode.org/reports/tr15. Include Unicode Signature (BOM) Includes a Byte Order Mark (BOM) in the document. A BOM is 2 to 4 bytes at the
beginning of a text file that identifies a file as Unicode, and if so, the byte order of the following bytes. Because UTF-8 has no byte order, adding a UTF-8 BOM is optional. For UTF-16 and UTF-32, it is required.
Use a tracing image to design a page You can insert an image file to use as a guide in designing your page. The image appears as a background image, which you can “design over” as you lay out your page. 1 Select Modify > Page Properties, or click the Page Properties button in the text Property inspector. 2 Choose the Tracing Image category and set the options. Tracing Image Specifies an image to use as a guide for copying a design. This image is for reference only, and does not
appear when the document is displayed in a browser. Transparency Determines the opacity of the tracing image, from completely transparent to completely opaque.
Understanding document encoding Document encoding specifies the encoding used for characters in the document. Document encoding is specified in a meta tag in the head of the document; it tells the browser and Dreamweaver how the document should be decoded and what fonts should be used to display the decoded text. For example, if you specify Western European (Latin1), this meta tag is inserted: .
Dreamweaver displays the document using the fonts you specify in Fonts Preferences for the Western European (Latin1) encoding; a browser displays the document using the fonts the browser user specifies for the Western European (Latin1) encoding. If you specify Japanese (Shift JIS), this meta tag is inserted: .
Dreamweaver displays the document using the fonts you specify for the Japanese encoding; a browser displays the document using the fonts the browser user specifies for the Japanese encodings.
Last updated 3/28/2012
202
USING DREAMWEAVER Adding content to pages
You can change document encoding for a page and change the default encoding that Dreamweaver uses to create new documents, including the fonts used to display each encoding.
More Help topics “Set default document type and encoding” on page 63
Select and view elements in the Document window To select an element in the Design view of the Document window, click the element. If an element is invisible, you must make it visible before you can select it. Some HTML code doesn’t have a visible representation in a browser. For example, comment tags don’t appear in browsers. However, it can be useful while you’re creating a page to be able to select such invisible elements, edit them, move them, and delete them. Dreamweaver enables you to specify whether it shows icons marking the location of invisible elements in the Design view of the Document window. To indicate which element markers appear, you can set options in Invisible Elements preferences. For example, you can specify that named anchors be visible, but not line breaks. You can create certain invisible elements (such as comments and named anchors) using buttons in the Common category of the Insert panel. You can then modify these elements using the Property inspector.
More Help topics “Viewing code” on page 281 “Use the Insert panel” on page 195
Select elements • To select a visible element in the Document window, click the element or drag across the element. • To select an invisible element, select View > Visual Aids > Invisible Elements (if that menu item isn’t already selected) and then click the element’s marker in the Document window. Some objects appear on the page in a place other than where their code is inserted. For example, in Design view an absolutely-positioned element (AP element) can be anywhere on the page, but in Code view the code defining the AP element is in a fixed location. When invisible elements are showing, Dreamweaver displays markers in the Document window to show the location of the code for such elements. Selecting a marker selects the entire element; for example, selecting the marker for an AP element selects the entire AP element.
• To select a complete tag (including its contents, if any), click a tag in the tag selector at the lower left of the Document window. (The tag selector appears in both Design view and Code view.) The tag selector always shows the tags that contain the current selection or insertion point. The leftmost tag is the outermost tag containing the current selection or insertion point. The next tag is contained in that outermost tag, and so on; the rightmost tag is the innermost one that contains the current selection or insertion point. In the following example, the insertion point is in a paragraph tag, . To select the table containing the paragraph you want to select, select the tag to the left of the tag.
Last updated 3/28/2012
203
USING DREAMWEAVER Adding content to pages
View the HTML code associated with the selected text or object ❖ Do one of the following:
• In the Document toolbar, click the Show Code View button. • Select View > Code. • In the Document toolbar, click the Show Code and Design Views button. • Select View > Code and Design. • Select Window > Code Inspector. When you select something in either code editor (Code view or the Code inspector), it’s generally also selected in the Document window. You may need to synchronize the two views before the selection appears.
Show or hide marker icons for invisible elements ❖ Select View > Visual Aids > Invisible Elements.
Note: Showing invisible elements may slightly change the layout of a page, moving other elements by a few pixels, so for precision layout, hide the invisible elements.
Set invisible elements preferences Use Invisible Elements preferences to specify which kinds of elements will be visible when you select View > Visual Aids > Invisible Elements. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh), then click Invisible Elements. 2 Select which elements should be made visible and click OK.
Note: A check mark next to the name of the element in the dialog box means the element is visible when View > Visual Aids > Invisible Elements is selected. Named Anchors Displays an icon that marks the location of each named anchor (a name = "") in the document.
Scripts Displays an icon that marks the location of JavaScript or VBScript code in the body of the document. Select
the icon to edit the script in the Property inspector or to link to an external script file. Comments Displays an icon that marks the location of HTML comments. Select the icon to see the comment in the
Property inspector. Line Breaks Displays an icon that marks the location of each line break (BR). This option is deselected by default. Client-Side Image Maps Displays an icon marking the location of each client-side image map in the document. Embedded Styles Displays an icon showing the location of CSS styles embedded in the body section of the document.
If CSS styles are placed in the head section of a document, they do not appear in the Document window. Hidden Form Fields Displays an icon that marks the location of form fields that have the type attribute set to "hidden".
Form Delimiter Displays a border around a form so you can see where to insert form elements. The border shows the
extent of the form tag, so any form elements inside that border are properly enclosed in form tags. Anchor Points For AP elements Displays an icon that marks the location of code defining an AP element. The AP
element itself can be anywhere on the page. (AP elements are not invisible elements; only the code defining the AP element is invisible.) Select the icon to select the AP element; you can then see the contents of the AP element even if the AP element is marked as hidden.
Last updated 3/28/2012
204
USING DREAMWEAVER Adding content to pages
Anchor Points For Aligned Elements Displays an icon showing the location of HTML code for elements that accept the align attribute. These include images, tables, ActiveX objects, plug-ins, and applets. In some cases, the code for the
element may be separated from the visible object. Visual Server Markup Tags Displays the location of server markup tags (such as Active Server Pages tags and ColdFusion tags) whose content cannot be displayed in the Document window. These tags typically generate HTML tags when processed by a server. For example, a tag generates an HTML table when processed by a ColdFusion server. Dreamweaver reperesents the tag with a ColdFusion invisible element since Dreamweaver cannot determine the final, dynamic output of the page. Nonvisual Server Markup Tags Displays the location of server markup tags (such as Active Server Pages tags and ColdFusion tags) whose content cannot be displayed in the Document window. These tags are typically set-up, processing, or logic tags (for example, , , and ) that do not generate HTML tags. CSS Display: None Displays an icon showing the location of content that’s hidden by the display:none property in the
linked or embedded stylesheet. Show Dynamic Text As Displays any dynamic text on your page in the format of {Recordset:Field} by default. If the length of these values is long enough to distort your page’s formatting, you can change the display to {} instead. Server-Side Includes Displays the actual contents of each server-side include file.
Colors Web-safe colors In HTML, colors are expressed either as hexadecimal values (for example, #FF0000) or as color names (red). A websafe color is one that appears the same in Safari and Microsoft Internet Explorer on both Windows and Macintosh systems when running in 256-color mode. The conventional wisdom is that there are 216 common colors, and that any hexadecimal value that combines the pairs 00, 33, 66, 99, CC, or FF (RGB values 0, 51, 102, 153, 204, and 255, respectively) represents a web-safe color. Testing, however, reveals that there are only 212 web-safe colors rather than a full 216, because Internet Explorer on Windows does not correctly render the colors #0033FF (0,51,255), #3300FF (51,0,255), #00FF33 (0,255,51), and #33FF00 (51,255,0). When web browsers first made their appearance, most computers displayed only 265 colors (8 bits per channel (bpc). Today, the majority of computers display thousands or millions of colors (16- and 32-bpc), so the justification for using the browser-safe palette is greatly diminished if you are developing your site for users with current computer systems. One reason to use the web-safe color palette is if you are developing for alternative web devices such as PDA and cell phone displays. Many of this devices offer only black and white (1-bpc) or 256 color (8-bpc) displays. The Color Cubes (default) and the Continuous Tone palettes in Dreamweaver use the 216-color web-safe palette; selecting a color from these palettes displays the color’s hexadecimal value. To select a color outside the web-safe range, open the system color picker by clicking the Color Wheel button in the upper-right corner of the Dreamweaver color picker. The system color picker is not limited to web-safe colors. UNIX versions of browsers use a different color palette than the Windows and Macintosh versions. If you are developing exclusively for UNIX browsers (or your target audience is Windows or Macintosh users with 24-bpc monitors and UNIX users with 8-bpc monitors), consider using hexadecimal values that combine the pairs 00, 40, 80, BF, or FF, which produce web-safe colors for SunOS.
Last updated 3/28/2012
205
USING DREAMWEAVER Adding content to pages
Use the color picker In Dreamweaver, many of the dialog boxes, as well as the Property inspector for many page elements, contain a color box, which opens a color picker. Use the color picker to select a color for a page element. You can also set the default text color for your page elements. 1 Click a color box in any dialog box or in the Property inspector.
The color picker appears. 2 Do one of the following:
• Use the eyedropper to select a color swatch from the palette. All colors in the Color Cubes (default) and Continuous Tone palettes are web-safe; other palettes are not.
• Use the eyedropper to pick up a color from anywhere on your screen—even outside the Dreamweaver windows. To pick up a color from the desktop or another application, press and hold the mouse button; this allows the eyedropper to retain focus, and select a color outside of Dreamweaver. If you click the desktop or another application, Dreamweaver picks up the color where you clicked. However, if you switch to another application, you may need to click a Dreamweaver window to continue working in Dreamweaver.
• To expand your color selection, use the pop-up menu at the upper-right corner of the color picker. You can select Color Cubes, Continuous Tone, Windows OS, Mac OS, and Grayscale. Note: The Color Cubes and Continuous Tone palettes are web-safe, whereas Windows OS, Mac OS and Grayscale are not.
• To clear the current color without choosing a different color, click the Default Color button • To open the system color picker, click the Color Wheel button
.
.
Zoom in and out Dreamweaver lets you increase the magnification (zoom in) in the Document window so that you can check the pixel accuracy of graphics, select small items more easily, design pages with small text, design large pages, and so on. Note: The zooming tools are only available in Design view.
More Help topics “Status bar overview” on page 11
Zoom in or out on a page 1 Click the Zoom tool (the magnifying glass icon) in the lower-right corner of the Document window. 2 Do one of the following:
• Click the spot on the page you want to magnify until you’ve achieved the desired magnification. • Drag a box over the area on the page that you want to zoom in on and release the mouse button. • Select a preset magnification level from the Zoom pop-up menu. • Type a magnification level in the Zoom text box. You can also zoom in without using the Zoom tool by pressing Control+= (Windows) or Command+= (Macintosh). 3 To zoom out (reduce magnification), select the Zoom tool, press Alt (Windows) or Option (Macintosh) and click
on the page.
Last updated 3/28/2012
206
USING DREAMWEAVER Adding content to pages
You can also zoom out without using the Zoom tool by pressing Control+- (Windows) or Command+- (Macintosh).
Edit a page after zooming ❖ Click the Select tool (the pointer icon) in the lower-right corner of the Document window, and click inside the page.
Pan a page after zooming 1 Click the Hand tool (the hand icon) in the lower-right corner of the Document window. 2 Drag the page.
Fill the Document window with a selection 1 Select an element on the page. 2 Select View > Fit Selection.
Fill the Document window with an entire page ❖ Select View > Fit All.
Fill the Document window with the entire width of a page ❖ Select View > Fit Width.
Set download time and size preferences Dreamweaver calculates size based on the entire contents of the page, including all linked objects, such as images and plug-ins. Dreamweaver estimates download time based on the connection speed entered in Status Bar preferences. Actual download time varies depending on general Internet conditions. A good guideline to use when checking download times for a particular web page is the 8-second rule. That is, most users will not wait longer than 8 seconds for a page to load. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Status Bar from the Category list on the left. 3 Select a connection speed with which to calculate download time and click OK.
More Help topics “Set window size and connection speed” on page 19
Last updated 3/28/2012
207
USING DREAMWEAVER Adding content to pages
Working with text Add text to a document To add text to a Dreamweaver document, you can type text directly in the Document window, or you can cut and paste text. You can also import text from other documents. When you paste text into a Dreamweaver document, you can use either the Paste or the Paste Special command. The Paste Special command lets you specify the format of pasted text in different ways. For example, if you wanted to paste text from a formatted Microsoft Word document into your Dreamweaver document, but wanted to strip out all of the formatting so that you could apply your own CSS style sheet to the pasted text, you could select the text in Word, copy it to your Clipboard, and use the Paste Special command to select the option that lets you paste text only. When using the Paste command to paste text from other applications, you can set paste preferences as default options. Note: Control+V (Windows) and Command+V (Macintosh) always paste text only (no formatting) in Code view. ❖ Add text to your document by doing one of the following:
• Type text directly into the Document window. • Copy text from another application, switch to Dreamweaver, position the insertion point in the Design view of the Document window, and select Edit > Paste or Edit > Paste Special. When you select Edit > Paste Special, you can select several paste formatting options. You can also paste text using the following keyboard shortcuts: Paste option
Keyboard shortcut
Paste
Control+V (Windows) Command+V (Macintosh)
Paste Special
Control+Shift+V (Windows) Command+Shift+V (Macintosh)
Insert special characters Certain special characters are represented in HTML by a name or a number, referred to as an entity. HTML includes entity names for characters such as the copyright symbol (©), the ampersand (&), and the registeredtrademark symbol (®). Each entity has both a name (such as —) and a numeric equivalent (such as ). HTML uses the angle brackets in its code, but you may need to express the special characters for greater than or less than without Dreamweaver interpreting them as code. In this case, use > for greater than (>) and < for less than ( HTML > Special Characters submenu. • In the Text category of the Insert panel, click the Characters button and select the character from the submenu.
Last updated 3/28/2012
208
USING DREAMWEAVER Adding content to pages
There are many other special characters available; to select one of them, select Insert > HTML > Special Characters > Other or click the Characters button in the Text category of the Insert panel and select the Other Characters option. Select a character from the Insert Other Character dialog box, and click OK.
Add space between characters HTML only allows for one space between characters; to add additional space in a document you must insert a nonbreaking space. You can set a preference to automatically add non-breaking spaces in a document.
Insert a non-breaking space ❖ Do one of the following:
• Select Insert > HTML > Special Characters > Non-Breaking Space. • Press Control+Shift+Spacebar (Windows) or Option+Spacebar (Macintosh). • In the Text category of the Insert panel, click the Characters button and select the Non-Breaking Space icon.
Set a preference to add non-breaking spaces 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 In the General category make sure Allow Multiple Consecutive Spaces is checked.
Add paragraph spacing Dreamweaver works similarly to many word processing application: you press Enter (Windows) or Return (Macintosh) to create a new paragraph. Web browsers automatically insert a blank line of space between paragraphs. You can add a single line of space between paragraphs by inserting a line break.
Add a paragraph return ❖ Press Enter (Windows) or Return (Macintosh).
Add a line break ❖ Do one of the following:
• Press Shift+Enter (Windows) or Shift+Return (Macintosh). • Select Insert > HTML > Special Characters > Line Break. • In the Text category of the Insert panel, click the Characters button and select the Line Break icon.
Create bulleted and numbered lists You can create numbered (ordered) lists, bulleted (unordered) lists, and definition lists from existing text or from new text as you type in the Document window. Definition lists do not use leading characters like bullet points or numbers and are often used in glossaries or descriptions. Lists can also be nested. Nested lists are lists that contain other lists. For example, you might want an ordered or bulleted list nested within another numbered or ordered list. You use the List Properties dialog box to set the appearance of an entire list or for an individual list item. You can set number style, reset numbering, or set bullet style options for individual list items or for the entire list.
Last updated 3/28/2012
209
USING DREAMWEAVER Adding content to pages
More Help topics “Set CSS properties” on page 127
Create a new list 1 In the Dreamweaver document, place the insertion point where you want to add a list, then do one of the following:
• In the HTML Property inspector, click either the Bulleted or Numbered List button. • Select Format > List and select the type of list desired—Unordered (bulleted) List, Ordered (numbered) List, or Definition List. The leading character for the specified list item appears in the Document window. 2 Type the list item text, then press Enter (Windows) or Return (Macintosh) to create another list item. 3 To complete the list, press Enter twice (Windows) or press Return twice (Macintosh).
Create a list using existing text 1 Select a series of paragraphs to make into a list. 2 In the HTML Property inspector, click the Bulleted or Numbered List button, or select Format > List and select the
type of list desired—Unordered List, Ordered List, or Definition List.
Create a nested list 1 Select the list items you want to nest. 2 In the HTML Property inspector, click the Blockquote button, or select Format > Indent.
Dreamweaver indents the text and creates a separate list with the original list’s HTML attributes. 3 Apply a new list type or style to the indented text by following the same procedure used above.
Set list properties for an entire list 1 In the Document window, create at least one list item. The new style will automatically apply to additional items
you add to the list. 2 With the insertion point in the list item’s text, select Format > List > Properties to open the List Properties dialog box. 3 Set the options you want to define the list: List Type Specifies list properties while List Item specifies an individual item in a list. Use the pop-up menu to select a bulleted, numbered, directory, or menu list. Depending on the List Type you select different options appear in the dialog box. Style Determines the style of numbers or bullets used for a numbered or bulleted list. All items in the list will have this style unless you specify a new style for items within the list. Start Count Sets the value for the first item in a numbered list.
4 Click OK to set the choices.
Set list properties for a list item 1 In the Document window, place the insertion point in the text of a list item you want to affect 2 Select Format > List > Properties.
Last updated 3/28/2012
210
USING DREAMWEAVER Adding content to pages
3 Under List Item, set the options you want to define: New Style Specifies a style for the selected list item. Styles in the New Style menu are related to the type of list displayed
in the List Type menu. For example, if the List Item menu displays Bulleted List, only bullet options are available in the New Style menu. Reset Count To Sets a specific number from which to number list item entries.
4 Click OK to set the options.
Search for and replace text You can use the Find And Replace command to search for text and for HTML tags and attributes in a document or a set of documents. The Search panel, in the Results panel group, shows the results of a Find All search. Note: To search for files in a site, use different commands: Locate In Local Site and Locate In Remote Site.
More Help topics “Viewing code” on page 281 “Regular expressions” on page 278
Search for and replace text 1 Open the document to search in, or select documents or a folder in the Files panel. 2 Select Edit > Find And Replace. 3 Use the Find In option to specify which files to search: Selected Text Confines the search to the text that’s currently selected in the active document. Current Document Confines the search to the active document. Open Documents Searches all documents that are currently open. Folder Confines the search to a specific folder. After choosing Folder, click the folder icon to browse to and select a
folder to search. Selected Files In Site Confines the search to the files and folders that are currently selected in the Files panel. Entire Current Local Site Expands the search to all the HTML documents, library files, and text documents in the
current site. 4 Use the Search pop-up menu to specify the kind of search you want to perform: Source Code Searches for specific text strings in the HTML source code. You can search for specific tags using this
option, but the Specific Tag search provides a more flexible approach to searching for tags. Text Searches for specific text strings in the text of the document. A text search ignores any HTML that interrupts the
string. For example, a search for the black dog would match both the black dog and the black dog.
Text (Advanced) Searches for specific text strings that are either within or not within a tag or tags. For example, in a
document that contains the following HTML, searching for tries and specifying Not Inside Tag and the i tag would find only the second instance of the word tries: John tries to get his work done on time, but he doesn't always succeed. He tries very hard. .
Specific Tag Searches for specific tags, attributes, and attribute values, such as all td tags with valign set to top.
Last updated 3/28/2012
211
USING DREAMWEAVER Adding content to pages
Note: Pressing Control+Enter or Shift+Enter (Windows), or Control+Return, Shift+Return, or Command+Return (Macintosh), adds line breaks within the text search fields, allowing you to search for a Return character. When performing such a search, deselect the Ignore Whitespace Differences option if you’re not using regular expressions. This search finds a Return character in particular, not simply the occurrence of a line break; for instance, it doesn’t find a tag or a tag. Return characters appear as spaces in the Design view, not as line breaks. 5 Use the following options to expand or limit the search: Match Case Limits the search to text that exactly matches the case of the text you want to find. For example, if you
search for the brown derby, you will not find The Brown Derby.
Ignore Whitespace Treats all whitespace as a single space for the purposes of matching. For example, with this option text but not thistext. This option is not available selected, this text would match this text and this when the Use Regular Expressions option is selected; you must explicitly write your regular expression to ignore whitespace. Note that and tags do not count as whitespace.
Match Whole Word Limits the search to text that matches one or more complete words.
Note: Using this option is equivalent to doing a regular-expression search for a search string that starts and ends with \b, the word-boundary regular expression. Use Regular Expressions Causes certain characters and short strings (such as ?, *, \w, and \b) in your search string to
be interpreted as regular expression operators. For example, a search for the b\w*\b dog will match both the black dog and the barking dog. Note: If you are working in Code view and make changes to your document, and try to find and replace anything other than source code, a dialog box appears letting you know that Dreamweaver is synchronizing the two views before doing the search. 6 To search without replacing, click Find Next or Find All: Find Next Jumps to and selects the next occurrence of the search text or tags in the current document. If there are no
more instances of the tag in the current document, Dreamweaver proceeds to the next document, if you are searching in more than one document. Find All Opens the Search panel in the Results panel group. If you are searching a single document, Find All displays all occurrences of the search text or tags, with some surrounding context. If you are searching a directory or site, Find All displays a list of documents that contain the tag.
7 To replace found text or tags, click Replace or Replace All. 8 When you’re finished, click Close.
Search again without displaying the Find And Replace dialog box ❖ Press F3 (Windows) or Command+G (Macintosh).
View a particular search result in context 1 Select Window > Results to display the Search panel. 2 Double-click a line in the Search panel.
If you’re searching the current file, the Document window displays the line containing that search result. If you’re searching a set of files, the file containing that search result opens.
Last updated 3/28/2012
212
USING DREAMWEAVER Adding content to pages
Perform the same search again ❖ Click the Find And Replace button.
Stop a search in progress ❖ Click the Stop button.
Search for a specific tag Use the Find And Replace dialog box to search for text or tags in a document, and to replace the found material with other text or tags. 1 Select Edit > Find And Replace. 2 In the Search pop-up menu, select Specific Tag. 3 Select a specific tag or [any tag] from the pop-up menu next to the Search pop-up menu, or type a tag name in
the text box. 4 (Optional.) Limit the search with one of the following tag modifiers: With Attribute Specifies an attribute that must be in the tag for it to match. You can specify a particular value for the
attribute or select [any value]. Without Attribute Selects an attribute that must not be in the tag for it to match. For example, select this option to
search for all img tags with no alt attribute. Containing Specifies text or a tag that must be contained within the original tag for it to match. For example, in the code heading 1, the font tag is contained within the b tag. Not Containing Specifies text or a tag that must not be contained within the original tag for it to match. Inside Tag Specifies a tag that the target tag must be contained in for it to match. Not Inside Tag Specifies a tag that the target tag must not be contained in for it to match.
5 (Optional.) To limit the search further, click the Plus (+) button and repeat step 3. 6 If you didn’t apply any tag modifiers in steps 3 and 4, then click the Minus (-) button to remove the tag modifiers
pop-up menu. 7 If you want to perform an action when the tag is found (such as removing or replacing the tag), select the action
from the Action pop-up menu and, if applicable, specify any additional information necessary to perform the action.
Search for specific text (Advanced) Use the Find and Replace dialog box to search for text or tags in a document, and to replace the found material with other text or tags. 1 Select Edit > Find and Replace. 2 In the Search pop-up menu, select Text (Advanced). 3 Enter text in the text field adjacent to the Search pop-up menu.
For example, type the word Untitled. 4 Select Inside Tag or Not Inside Tag, and then select a tag from the adjacent pop-up menu.
For example, select Inside Tag and then title.
Last updated 3/28/2012
213
USING DREAMWEAVER Adding content to pages
5 (Optional.) Click the Plus (+) button to limit the search with one of the following tag modifiers: With Attribute Specifies an attribute that must be in the tag for it to match. You can specify a particular value for the
attribute or select [any value]. Without Attribute Selects an attribute that must not be in the tag for it to match. For example, select this option to
search for all img tags with no alt attribute. Containing Specifies text or a tag that must be contained within the original tag for it to match. For example, in the
code heading 1, the font tag is contained within the b tag.
Not Containing Specifies text or a tag that must not be contained within the original tag for it to match. Inside Tag Specifies a tag that the target tag must be contained in for it to match. Not Inside Tag Specifies a tag that the target tag must not be contained in for it to match.
6 (Optional.) To limit the search further, repeat step 4.
Define abbreviations and acronyms HTML provides tags that let you define the abbreviations and acronyms you use in your page for search engines, spell checkers, language translation programs, or speech synthesizers. For example, you might want to specify that the abbreviation ME in your page stands for mechanical engineer, or the acronym WHO stands for World Health Organization. 1 Select the abbreviation or acronym in the text of your page. 2 Select Insert > HTML > Text Objects > Abbreviation, or Insert > HTML > Text Objects > Acronym. 3 Enter the full text of the acronym or abbreviation. 4 Enter the language, such as en for English, de for German, or it for Italian.
Set copy and paste preferences You can set special paste preferences as default options when using Edit > Paste to paste text from other applications. For example, if you always want to paste text as text only, or text with basic formatting, you can set the default option in the Copy/Paste Preferences dialog box. Note: When you paste text into a Dreamweaver document, you can use either the Paste or the Paste Special command. The Paste Special command lets you specify the format of pasted text in different ways. For example, if you wanted to paste text from a formatted Microsoft Word document into your Dreamweaver document, but wanted to strip out all of the formatting so that you could apply your own CSS style sheet to the pasted text, you could select the text in Word, copy it to your Clipboard, and use the Paste Special command to select the option that lets you paste text only. Note: Preferences set in the Copy/Paste Preferences dialog box apply only to material pasted into Design view. 1 Select Edit > Preferences (Windows) or Dreamweaver Preferences (Macintosh). 2 Click the Copy/Paste category. 3 Set the following options and click OK. Text Only Lets you paste unformatted text. If the original text is formatted, all formatting, including line breaks and
paragraphs, will be removed. Text With Structure Lets you paste text that retains structure, but does not retain basic formatting. For example, you can paste text and retain the structure of paragraphs, lists, and tables, without retaining bold, italics, and other formatting.
Last updated 3/28/2012
214
USING DREAMWEAVER Adding content to pages
Text With Structure Plus Basic Formatting Lets you paste both structured and simple HTML-formatted text (e.g.,
paragraphs and tables, as well as text formatted with the b, i, u, strong, em, hr, abbr, or acronym tag). Text With Structure Plus Full Formatting Lets you paste text that retains all structure, HTML formatting, and CSS
styles. Note: The Full Formatting option cannot retain CSS styles that come from an external style sheet, nor can it retain styles if the application from which you are pasting does not retain styles upon pasting to the Clipboard. Retain Line Breaks Lets you keep line breaks in pasted text. This option is disabled if you have selected Text Only. Clean Up Word Paragraph Spacing Select this option if you selected Text With Structure or Text With Structure Plus
Basic Formatting, and want to eliminate extra space between paragraphs when you paste your text.
Set text properties in the Property inspector You can use the text Property inspector to apply HTML formatting or Cascading Style Sheet (CSS) formatting. When you apply HTML formatting, Dreamweaver adds properties to the HTML code in the body of your page. When you apply CSS formatting, Dreamweaver writes properties to the head of the document or to a separate style sheet. Note: When you create CSS inline styles, Dreamweaver adds style attribute code directly to the body of the page.
About formatting text (CSS versus HTML) Formatting text in Dreamweaver is similar to using a standard word processor. You can set default formatting styles (Paragraph, Heading 1, Heading 2, and so on) for a block of text, change the font, size, color, and alignment of selected text, or apply text styles such as bold, italic, code (monospace), and underline. Dreamweaver has two Property inspectors, integrated into one: the CSS Property inspector and the HTML Property inspector. When you use the CSS Property inspector, Dreamweaver formats text using Cascading Style Sheets (CSS). CSS gives web designers and developers greater control over web page design, while providing improved features for accessibility and reduced file size. The CSS Property inspector lets you access existing styles, as well as create new ones. Using CSS is a way to control the style of a web page without compromising its structure. By separating visual design elements (fonts, colors, margins, and so on) from the structural logic of a web page, CSS gives web designers visual and typographic control without sacrificing the integrity of the content. In addition, defining typographic design and page layout from within a single, distinct block of code—without having to resort to image maps, font tags, tables, and spacer GIFs—allows for faster downloads, streamlined site maintenance, and a central point from which to control design attributes across multiple web pages. You can store styles created with CSS directly in the document, or for more power and flexibility, you can store styles in an external style sheet. If you attach an external style sheet to several web pages, all the pages automatically reflect any changes you make to the style sheet. To access all CSS rules for a page, use the CSS Styles panel (Window > CSS Styles). To access rules that apply to a current selection, use the CSS Styles panel (Current mode) or the Targeted Rule pop-up menu in the CSS Property inspector. If you prefer, you can use HTML markup tags to format text in your web pages. To use HTML tags instead of CSS, format your text using the HTML Property inspector. Note: You can combine CSS and HTML 3.2 formatting within the same page. Formatting is applied in a hierarchical manner: HTML 3.2 formatting overrides formatting applied by external CSS style sheets, and CSS embedded in a document overrides external CSS.
Last updated 3/28/2012
215
USING DREAMWEAVER Adding content to pages
More Help topics “Open the CSS Styles panel” on page 124 “Understanding Cascading Style Sheets” on page 116
Edit CSS rules in the Property inspector 1 Open the Property inspector (Window > Properties), if it isn’t already open and click the CSS button. 2 Do one of the following:
• Place the insertion point inside a block of text that’s been formatted by a rule you want to edit. The rule appears in the Targeted Rule pop-up menu.
• Select a rule from the Targeted Rule pop-up menu. 3 Make changes to the rule by using the various options in the CSS Property inspector. Targeted Rule Is the rule you are editing in the CSS Property inspector. When you have an existing style applied to
text, the rule affecting the text’s format appears when you click inside the text on the page. You can also use the Targeted Rule pop-up menu to create new CSS rules, new in-line styles, or apply existing classes to selected text. If you’re creating a new rule, you’ll need to complete the New CSS Rule dialog box. For more information, see the links at the end of this topic. Edit Rule Opens the CSS Rule Definition dialog box for the targeted rule. If you select New CSS Rule from the Targeted Rule pop-up menu and click the Edit Rule button, Dreamweaver opens the New CSS Rule definition dialog box instead. CSS Panel Opens the CSS Styles panel and displays properties for the targeted rule in Current view. Font Changes the font of the targeted rule. Size Sets the font size for the targeted rule. Text Color Sets the selected color as the font color in the targeted rule. Select a web-safe color by clicking the color box, or enter a hexadecimal value (for example, #FF0000) in the adjacent text field. Bold Adds the bold property to the targeted rule. Italic Adds the italics property to the targeted rule. Left, Center, and Right Align Adds the respective alignment properties to the targeted rule.
Note: The Font, Size, Text Color, Bold, Italic, and Alignment properties always display the properties for the rule that applies to the current selection in the Document window. When you change any of these properties, you affect the targeted rule. For a video tutorial about working with the CSS Property inspector, see www.adobe.com/go/lrvid4041_dw.
Set HTML formatting in the Property inspector 1 Open the Property inspector (Window > Properties), if it isn’t already open, and click the HTML button. 2 Select the text you want to format. 3 Set the options you want to apply to the selected text: Format Sets the paragraph style of the selected text. Paragraph applies the default format for a tag, Heading 1 adds an H1 tag, and so on. ID Assigns an ID to your selection. The ID pop-up menu (if applicable) lists all of the document’s unused, declared IDs.
Last updated 3/28/2012
216
USING DREAMWEAVER Adding content to pages
Class Displays the class style that is currently applied to the selected text. If no styles have been applied to the selection,
the pop-up menu shows No CSS Style. If multiple styles have been applied to the selection, the menu is blank. Use the Style menu to do any of the following:
• Select the style you want to apply to the selection. • Select None to remove the currently selected style. • Select Rename to rename the style. • Select Attach Style Sheet to open a dialog box that lets you attach an external style sheet to the page. Bold Applies either or to the selected text according to the style preference set in the General category of the Preferences dialog box. Italic Applies either or to the selected text according to the style preference set in the General category of the
Preferences dialog box. Unordered List Creates a bulleted list of the selected text. If no text is selected, a new bulleted list is started. Ordered List Creates a numbered list of the selected text. If no text is selected, a new numbered list is started. Blockquote and Remove Blockquote Indent or remove indentation from the selected text by applying or removing the blockquote tag. In a list, indenting creates a nested list and removing the indentation unnests the list.
Link Creates a hypertext link of the selected text. Click the folder icon to browse to a file in your site; type the URL;
drag the Point-To-File icon to a file in the Files panel; or drag a file from the Files panel into the box. Title Specifies the textual tooltip for a hypertext link. Target Specifies the frame or window in which the linked document will load:
•
_blank loads the linked file in a new, unnamed browser window.
•
_parent loads the linked file in the parent frameset or window of the frame that contains the link. If the frame
containing the link is not nested, the linked file loads into the full browser window.
•
_self loads the linked file in the same frame or window as the link. This target is implied, so you generally don’t
need to specify it.
•
_top loads the linked file in the full browser window, thereby removing all frames.
Rename a class from the HTML Property inspector Dreamweaver displays all of the classes available to your page in the Class menu of the HTML Property inspector. You can rename styles in this list by selecting the Rename option at the end of the list of class styles. 1 Select Rename from the text Property inspector Style pop-up menu. 2 Select the style you want to rename from the Rename Style pop-up menu. 3 Enter a new name in the New Name text field and click OK.
Spell check a web page Use the Check Spelling command to check the spelling in the current document. The document must be a web page (for example, an HTML, ColdFusion, or PHP page). The Check Spelling command does not work on text files or XML files. Additionally, the Check Spelling command ignores HTML tags and attribute values.
Last updated 3/28/2012
217
USING DREAMWEAVER Adding content to pages
Note: Dreamweaver can only spell check the file that is currently open in the Document window. It cannot spell check all of the files in a site simultaneously. By default, the spelling checker uses the U.S. English spelling dictionary. To change the dictionary, select Edit > Preferences > General (Windows) or Dreamweaver > Preferences > General (Macintosh), then in the Spelling Dictionary pop-up menu select the dictionary you want to use. 1 Select Commands > Check Spelling or press Shift+F7.
When Dreamweaver encounters an unrecognized word, the Check Spelling dialog box appears. 2 Select the appropriate option based on how you want the discrepancy handled. Add To Personal Adds the unrecognized word to your personal dictionary. Ignore Ignores this instance of the unrecognized word. Change Replaces this instance of the unrecognized word with text that you type in the Change To text box or with
the selection in the Suggestions list. Ignore All Ignores all instances of the unrecognized word. Change All Replaces all instances of the unrecognized word in the same manner.
Note: Dreamweaver does not provide a way of deleting entries that have been added to personal dictionaries.
Import tabular data You can import tabular data into your document by first saving the files (such as Microsoft Excel files or database files) as delimited text files. You can import and format tabular data and import text from Microsoft Word HTML documents. You can also add text from Microsoft Excel documents to a Dreamweaver document by importing the contents of the Excel file into a web page. 1 Select File > Import > Import Tabular Data, or Insert > Table Objects > Import Tabular Data. 2 Browse for the file you want or enter its name in the text box. 3 Select the delimiter used when the file was saved as delimited text. Your options are Tab, Comma, Semicolon,
Colon, and Other. If you select Other, a blank field appears next to the option. Enter the character that was used as a delimiter. 4 Use the remaining options to format or define the table into which the data will be imported and click OK.
More Help topics “Open and edit existing documents” on page 65 “Import and export tabular data” on page 169
Last updated 3/28/2012
218
USING DREAMWEAVER Adding content to pages
Import Microsoft Office documents (Windows only) You can insert the full contents of a Microsoft Word or Excel document in a new or existing web page. When you import a Word or Excel document, Dreamweaver receives the converted HTML and inserts it into your web page. The file’s size, after Dreamweaver receives the converted HTML, must be less than 300K. Instead of importing the entire contents of a file, you can also paste portions of a Word document and preserve the formatting. Note: If you use Microsoft Office 97, you cannot import the contents of a Word or Excel document; you must insert a link to the document. 1 Open the web page into which you want to insert the Word or Excel document. 2 In Design view, do one of the following to select the file:
• Drag the file from its current location to the page where you want the content to appear. • Select File > Import > Word Document or File > Import > Excel Document. 3 In the Insert Document dialog box, browse to the file you want to add, select any of the formatting options from
the Formatting pop-up menu at the bottom of the dialog box, and then click Open. Text Only Inserts unformatted text. If the original text is formatted, all formatting will be removed. Text With Structure Inserts text that retains structure, but does not retain basic formatting. For example, you can paste text and retain the structure of paragraphs, lists, and tables, without retaining bold, italics, and other formatting. Text With Structure Plus Basic Formatting Inserts both structured and simple HTML-formatted text (e.g., paragraphs
and tables, as well as text formatted with the b, i, u, strong, em, hr, abbr, or acronym tag). Text With Structure Plus Full Formatting Inserts text that retains all structure, HTML formatting, and CSS styles. Clean Up Word Paragraph Spacing Eliminates extra space between paragraphs when you paste your text if you
selected Text With Structure or Basic Formatting. The contents of the Word or Excel document appear in your page.
Create a link to a Word or Excel document You can insert a link to a Microsoft Word or Excel document in an existing page. 1 Open the page where you want the link to appear. 2 Drag the file from its current location to your Dreamweaver page, positioning the link wherever you want. 3 Select Create A Link, and then click OK. 4 If the document you are linking to is located outside of your site’s root folder, Dreamweaver prompts you to copy
the document to the site root. By copying the document to the site’s root folder, you ensure that the document will be available when you publish the website. 5 When you upload your page to your web server, make sure to upload the Word or Excel file, too.
Your page now contains a link to the Word or Excel document. The link text is the name of the linked file; you can change the link text in the Document window if you wish.
Last updated 3/28/2012
219
USING DREAMWEAVER Adding content to pages
Use HTML Formatting While CSS is the preferred method for formatting text, Dreamweaver still lets you format text with HTML.
Format paragraphs Use the Format pop-up menu in the HTML Property inspector or the Format > Paragraph Format submenu to apply the standard paragraph and heading tags. 1 Place the insertion point in the paragraph, or select some of the text in the paragraph. 2 Using the Format > Paragraph Format submenu or the Format pop-up menu in the Property inspector, select an
option:
• Select a paragraph format (for example, Heading 1, Heading 2, Preformatted Text, and so on). The HTML tag associated with the selected style (for example, h1 for Heading 1, h2 for Heading 2, pre for Preformatted text, and so on) is applied to the entire paragraph.
• Select None to remove a paragraph format. When you apply a heading tag to a paragraph, Dreamweaver automatically adds the next line of text as a standard paragraph. To change this setting, select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh); then in the General category, under Editing Options, make sure Switch To Plain Paragraph After Heading is not selected.
More Help topics “Set text properties in the Property inspector” on page 214 “Set CSS properties” on page 127
Change the color of text You can change the default color of all the text in a page, or you can change the color of selected text in the page.
More Help topics “Use the color picker” on page 205
Define default text colors for a page ❖ Select Modify > Page Properties > Appearance (HTML) or Links (HTML), and then select colors for the Text Color,
Link Color, Visited Links, and Active Links options. Note: The active link color is the color that a link changes to while it’s being clicked. Some web browsers may not use the color you specify.
Change the color of selected text ❖ Select Format > Color, select a color from the system color picker, and then click OK.
Align text You align text with HTML using the Format > Align submenu. You can center any element on a page using the Format > Align > Center command.
Last updated 3/28/2012
220
USING DREAMWEAVER Adding content to pages
Align text on a page 1 Select the text you want to align or simply insert the pointer at the beginning of the text. 2 Select Format > Align and select an alignment command.
Center page elements 1 Select the element (image, plug-in, table, or other page element) you want to center. 2 Select Format > Align > Center.
Note: You can align and center complete blocks of text; you cannot align or center part of a heading or part of a paragraph.
Indent text Using the Indent command applies the blockquote HTML tag to a paragraph of text, indenting text on both sides of the page. 1 Place the insertion point in the paragraph you want to indent. 2 Select Format > Indent or Outdent, or select List > Indent or Outdent from the context menu.
Note: You can apply multiple indents to a paragraph. Each time you select this command, the text indents further from both sides of the document.
Apply font styles You can use HTML to apply text formatting to one letter, or to entire paragraphs and blocks of text in a site. Use the Format menu to set or change font characteristics for selected text. You can set the font type, style (such as bold or italic), and size. 1 Select the text. If no text is selected, the option applies to subsequent text you type. 2 Select from the following options:
• To change the font, select a font combination from the Format > Font submenu. Select Default to remove previously applied fonts. Default applies the default font for the selected text (either the browser default font or the font assigned to that tag in the CSS style sheet).
• To change the font style, select a font style (Bold, Italic, Underline, and so on) from the Format > Style submenu.
More Help topics “Creating pages with CSS” on page 116 “Create a new CSS rule” on page 126
Use horizontal rules Horizontal rules (lines) are useful for organizing information. On a page, you can visually separate text and objects with one or more rules.
Create a horizontal rule 1 In the Document window, place the insertion point where you want to insert a horizontal rule.
Last updated 3/28/2012
221
USING DREAMWEAVER Adding content to pages
2 Select Insert > HTML > Horizontal Rule.
Modify a horizontal rule 1 In the Document window, select the horizontal rule. 2 Select Window > Properties to open the Property inspector, and modify the properties as desired: The ID text box Lets you specify an ID for the horizontal rule. W and H Specify the width and height of the rule in pixels or as a percentage of the page size. Align Specifies the alignment of the rule (Default, Left, Center, or Right). This setting applies only if the width of the
rule is less than the width of the browser window. Shading Specifies whether the rule is drawn with shading. Deselect this option to draw the rule in a solid color. Class Lets you attach a style sheet, or apply a class from an already attached style sheet.
Modify font combinations Use the Edit Font List command to set the font combinations that appear in the Property inspector and the Format > Font submenu. Font combinations determine how a browser displays text in your web page. A browser uses the first font in the combination that is installed on the user’s system; if none of the fonts in the combination is installed, the browser displays the text as specified by the user’s browser preferences.
Modify font combinations 1 Select Format > Font > Edit Font List. 2 Select the font combination from the list at the top of the dialog box.
The fonts in the selected combination are listed in the Chosen Fonts list in the lower-left corner of the dialog box. To the right is a list of all available fonts installed on your system. 3 Do one of the following:
• To add or remove fonts from a font combination, click the arrows button (>) between the Chosen Fonts list and the Available Fonts list.
• To add or remove a font combination, click the Plus (+) and Minus (–) buttons at the top of the dialog box. • To add a font that is not installed on your system, type the font name in the text field below the Available Fonts list and click the Font > Edit Font List. 2 Select a font from the Available Fonts list and click the Assets) to the desired location in the Document window; then skip to step 3.
• Drag an image from the Files panel to the desired location in the Document window; then skip to step 3. • Drag an image from the desktop to the desired location in the Document window; then skip to step 3. 2 In the dialog box that appears, do one of the following:
• Select File System to choose an image file. • Select Data Source to choose a dynamic image source. • Click the Sites And Servers button to choose an image file in a remote folder of one of your Dreamweaver sites. 3 Browse to select the image or content source you want to insert.
If you are working in an unsaved document, Dreamweaver generates a file:// reference to the image file. When you save the document anywhere in the site, Dreamweaver converts the reference to a document-relative path. Note: When inserting images it’s also possible to use an absolute path to an image that resides on a remote server (i.e., an image that is not available on the local hard drive). If you experience performance problems while working, however, you might want to disable viewing the image in Design view by deselecting Commands > Display External Files. 4 Click OK. The Image Tag Accessibility Attributes dialog box appears if you have activated the dialog box in
Preferences (Edit > Preferences).
Last updated 3/28/2012
224
USING DREAMWEAVER Adding content to pages
5 Enter values in the Alternate Text and Long Description text boxes, and click OK.
• In the Alternate Text box, enter a name or brief description for the image. The screen reader reads the information you enter here. You should limit your entry to around 50 characters. For longer descriptions, consider providing a link, in the Long Description text box, to a file that gives more information about the image.
• In the Long Description box, enter the location of a file that displays when the user clicks the image or click the folder icon to browse to the file. This text box provides a link to a file that is related to, or gives more information about, the image. Note: You can enter information in one or both text boxes depending on your needs. The screen reader reads the Alt attribute for the image. Note: If you click Cancel, the image appears in the document, but Dreamweaver does not associate accessibility tags or attributes with it. 6 In the Property inspector (Window > Properties), set properties for the image.
More Help topics “Make images dynamic” on page 551 “Image maps” on page 268 “Optimize the work space for accessible page design” on page 653 “Set page properties” on page 198 Inserting images tutorial
Set image properties The Images Property inspector allows you to set properties for an image. If you do not see all of the image properties, click the expander arrow in the lower-right corner.
1 Select Window > Properties to view the Property inspector for a selected image. 2 In the text box below the thumbnail image, enter a name so you can refer to the image when using a Dreamweaver
behavior (such as Swap Image) or when using a scripting language such as JavaScript or VBScript. 3 Set any of the image options. W and H The width and height of the image, in pixels. Dreamweaver automatically updates these text boxes with the image’s original dimensions when you insert an image in a page.
If you set W and H values that do not correspond to the actual width and height of the image, the image may not display properly in a browser. (To restore the original values, click the W and H text box labels, or the Reset image size button that appears to the right of the W and H text boxes in entering a new value.) Note: You can change these values to scale the display size of this image instance, but this does not reduce download time, because the browser downloads all image data before scaling the image. To reduce download time and to ensure that all instances of an image appear at the same size, use an image-editing application to scale images.
Last updated 3/28/2012
225
USING DREAMWEAVER Adding content to pages
Src Specifies the source file for the image. Click the folder icon to browse to the source file, or type the path. Link Specifies a hyperlink for the image. Drag the Point-To-File icon to a file in the Files panel, click the folder icon to
browse to a document on your site, or manually type the URL. Align Aligns an image and text on the same line. Alt Specifies alternative text that appears in place of the image for text-only browsers or for browsers that have been
set to download images manually. For visually impaired users who use speech synthesizers with text-only browsers, the text is spoken out loud. In some browsers, this text also appears when the pointer is over the image. Map Name and Hotspot tools Allow you to label and create a client-side image map. V Space and H Space Add space, in pixels, along the sides of the image. V Space adds space along the top and bottom
of an image. H Space adds space along the left and right of an image. Target Specifies the frame or window in which the linked page should load. (This option is not available when the image isn’t linked to another file.) The names of all the frames in the current frameset appear in the Target list. You can also choose from the following reserved target names:
•
_blank loads the linked file into a new, unnamed browser window.
•
_parent loads the linked file into the parent frameset or window of the frame that contains the link. If the frame
containing the link is not nested, the linked file loads into the full browser window.
•
_self loads the linked file into the same frame or window as the link. This target is the default, so you usually don’t
need to specify it.
•
_top loads the linked file into the full browser window, thereby removing all frames.
Border The width, in pixels, of the image’s border. The default is no border. Edit Starts the image editor you specified in External Editors preferences and opens the selected image. Edit image settings Crop
Opens the Image Preview dialog box and lets you optimize the image.
Trims the size of an image, removing unwanted areas from the selected image.
Resample
Resamples a resized image, improving its picture quality at its new size and shape.
Brightness and Contrast Sharpen
Adjusts the brightness and contrast settings of an image.
Adjusts the sharpness of an image.
Resets the W and H values to the original size of the image. This button appears to the right of the W and H text boxes when you adjust the values of the selected image. Reset Size
Edit image accessibility attributes in code If you inserted accessibility attributes for an image, you can edit those values in the HTML code. 1 In the Document window, select the image. 2 Do one of the following:
• Edit the appropriate image attributes in Code view. • Right-click (Windows) or Control-click (Macintosh), and then select Edit Tag. • Edit the Alt value in the Property inspector.
Last updated 3/28/2012
226
USING DREAMWEAVER Adding content to pages
Align an image You can align an image to text, another image, a plug-in, or other elements in the same line. You can also set the horizontal alignment of an image. 1 Select the image in Design view. 2 Set the alignment attributes of the image in the Property inspector with the Align popup menu.
You can set the alignment in relation to other elements in the same paragraph or line. Note: HTML does not provide a way to wrap text around the contours of an image, as you can with some word processing applications. The alignment options are as follows: Default Specifies a baseline alignment. (The default may vary depending on the site visitor’s browser.) Baseline and Bottom Align the baseline of the text (or other element in the same paragraph) to the bottom of the
selected object. Top Aligns the top of an image to the top of the tallest item (image or text) in the current line. Middle Aligns the middle of the image with the baseline of the current line. Text Top Aligns the top of the image with the top of the tallest character in the text line. Absolute Middle Aligns the middle of the image with the middle of the text in the current line. Absolute Bottom Aligns the bottom of the image with the bottom of the line of text (which includes descenders, as in
the letter g). Left Places the selected image on the left margin, wrapping text around it to the right. If left-aligned text precedes the
object on the line, it generally forces left-aligned objects to wrap to a new line. Right Places the image on the right margin, wrapping text around the object to the left. If right-aligned text precedes
the object on the line, it generally forces right-aligned objects to wrap to a new line.
Visually resize an image You can visually resize elements such as images, plug-ins, Shockwave or SWF files, applets, and ActiveX controls in Dreamweaver. Visually resizing an image helps you see how the image affects the layout at different dimensions but it does not scale the image file to the proportions that you specify. If you visually resize an image in Dreamweaver without using an image-editing application (such as Adobe Fireworks) to scale the image file to the desired size, the user’s browser scales the image when the page is loaded. This might cause a delay in page download time and the improper display of the image in the user’s browser. To reduce download time and to ensure that all instances of an image appear at the same size, use an image-editing application to scale images. When you resize an image in Dreamweaver, you can resample it to accommodate its new dimensions. Resampling adds or subtracts pixels from a resized JPEG and GIF image files to match the appearance of the original image as closely as possible. Resampling an image reduces its file size and improves download performance.
More Help topics “Edit images in Dreamweaver” on page 229
Visually resize an element 1 Select the element (for example, an image or SWF file) in the Document window.
Last updated 3/28/2012
227
USING DREAMWEAVER Adding content to pages
Resize handles appear at the bottom and right sides of the element and in the lower-right corner. If resize handles don’t appear, click somewhere other than the element you want to resize and then reselect it, or click the appropriate tag in the tag selector to select the element. 2 Resize the element by doing one of the following:
• To adjust the width of the element, drag the selection handle on the right side. • To adjust the height of the element, drag the bottom selection handle. • To adjust the width and the height of the element at the same time, drag the corner selection handle. • To preserve the element’s proportions (its width-to-height ratio) as you adjust its dimensions, Shift-drag the corner selection handle.
•
To adjust the width and height of an element to a specific size (for example, 1 x 1 pixel), use the Property inspector to enter a numeric value. Elements can be visually resized to a minimum of 8 x 8 pixels.
3 To return a resized element to its original dimensions, in the Property inspector, delete the values in the W and H
text boxes, or click the Reset Size button in the image Property inspector.
Revert an image to its original size ❖ Click the Reset size button
in the image Property inspector.
Resample a resized image 1 Resize the image as described above. 2 Click the Resample button
in the image Property inspector.
Note: You cannot resample image placeholders or elements other than bitmap images.
Insert an image placeholder An image placeholder is a graphic you use until final artwork is ready to be added to a web page. You can set the placeholder’s size and color, as well as provide it with a text label. 1 In the Document window, place the insertion point where you want to insert a placeholder graphic. 2 Select Insert > Image Objects > Image Placeholder. 3 For Name (Optional), enter text you want to appear as a label for the image placeholder. Leave the text box blank
if you do not want a label to appear. The name must begin with a letter and can contain only letters and numbers; spaces and high ASCII characters are not allowed. 4 For Width and Height (Required), type a number to set the image size in pixels. 5 For Color (Optional), do one of the following to apply a color:
• Use the color picker to select a color. • Enter the color’s hexadecimal value (for example, #FF0000). • Enter a web-safe color name (for example, red). 6 For Alternate Text (Optional), enter text to describe the image for viewers using a text-only browser.
Note: An image tag is automatically inserted into the HTML code containing an empty src attribute. 7 Click OK.
Last updated 3/28/2012
228
USING DREAMWEAVER Adding content to pages
The placeholder’s color, size attributes, and label appear as follows:
When viewed in a browser, the label and size text do not appear.
More Help topics “Visually resize an image” on page 226 “Use Fireworks to modify Dreamweaver image placeholders” on page 344
Replace an image placeholder An image placeholder does not display an image in a browser. Before you publish your site you should replace any image placeholders you’ve added with web-friendly image files, such as GIFs or JPEGs. If you have Fireworks, you can create a new graphic from the Dreamweaver image placeholder. The new image is set to the same size as the placeholder image. You can edit the image, then replace it in Dreamweaver. 1 In the Document window, do one of the following:
• Double-click the image placeholder. • Click the image placeholder to select it; then in the Property inspector (Window > Properties), click the folder icon next to the Src text box. 2 In the Image Source dialog box, navigate to the image you want to replace the image placeholder with and click OK.
More Help topics “Use Fireworks to modify Dreamweaver image placeholders” on page 344
Set image placeholder properties To set properties for an image placeholder, select the placeholder in the Document window; then select Window > Properties to display the Property inspector. To see all properties, click the expander arrow in the lower-right corner. Use the Property inspector to set a name, width, height, image source, alternate text description, alignment and color for a placeholder image.
In the placeholder Property inspector, the gray text box and the Align text box are disabled. You can set these properties in the image Property inspector when you replace the placeholder with an image. ❖ Set any of the following options: W and H Set the width and height of the image placeholder, in pixels.
Last updated 3/28/2012
229
USING DREAMWEAVER Adding content to pages
Src Specifies the source file for the image. For a placeholder image, this text box is empty. Click the Browse button to select a replacement image for the placeholder graphic. Link Specifies a hyperlink for the image placeholder. Drag the Point-to-File icon to a file in the Files panel, click the
folder icon to browse to a document on your site, or manually type the URL. Alt Specifies alternative text that appears in place of the image for text-only browsers or for browsers that have been
set to download images manually. For visually impaired users who use speech synthesizers with text-only browsers, the text is spoken out loud. In some browsers, this text also appears when the pointer is over the image. Create Starts Fireworks to create a replacement image. The Create button is disabled unless Fireworks is also installed on your computer. Reset Size Resets the W and H values to the original size of the image. Color Specifies a color for the image placeholder.
More Help topics “Use Fireworks to modify Dreamweaver image placeholders” on page 344
Edit images in Dreamweaver You can resample, crop, optimize, and sharpen images in Dreamweaver. You can also adjust their brightness and contrast.
Image-editing features Dreamweaver provides basic image-editing features that let you modify images without having to use an external image-editing application such as Fireworks or Photoshop. The Dreamweaver image-editing tools are designed to let you easily work with content designers responsible for creating image files for use on your website. Note: You do not need to have Fireworks or other image-editing applications installed on your computer to use the Dreamweaver image-editing features. ❖ Select Modify > Image. Set any of these Dreamweaver image-editing features: Resample Adds or subtracts pixels from a resized JPEG and GIF image files to match the appearance of the original image as closely as possible. Resampling an image reduces its file size and improves download performance.
When you resize an image in Dreamweaver, you can resample it to accommodate its new dimensions. When a bitmap object is resampled, pixels are added to or removed from the image to make it larger or smaller. Resampling an image to a higher resolution typically causes little loss of quality. Resampling to a lower resolution, however, always causes data loss and usually a drop in quality. Crop Edit images by reducing the area of the image. Typically, you’ll want to crop an image to place more emphasis
on the subject of the image, and remove unwanted aspects surrounding the center of interest in the image. Brightness and Contrast Modifies the contrast or brightness of pixels in an image. This affects the highlights, shadows, and midtones of an image. You typically use Brightness/Contrast when correcting images that are too dark or too light. Sharpen Adjusts the focus of an image by increasing the contrast of edges found within the image. When you scan an
image, or take a digital photo, the default action of most image capturing software is to soften the edges of objects in the image. This prevents extremely fine details from becoming lost in the pixels from which digital images are composed. However, to bring out the details in digital image files, it is often necessary to sharpen the image, thereby increasing edge contrast, and making the image appear sharper.
Last updated 3/28/2012
230
USING DREAMWEAVER Adding content to pages
Note: Dreamweaver image-editing features apply only to JPEG, GIF, and PNG image file formats. Other bitmap image file formats cannot be edited using these image-editing features.
Crop an image Dreamweaver lets you crop (or trim) bitmap file images. Note: When you crop an image, the source image file is changed on disk. For this reason, you may want to keep a backup copy of the image file in the event you need to revert to the original image. 1 Open the page containing the image you want to crop, select the image, and do either of the following:
• Click the Crop Tool icon
in the image Property inspector.
• Select Modify > Image > Crop. Crop handles appear around the selected image. 2 Adjust the crop handles until the bounding box surrounds the area of the image that you want to keep. 3 Double-click inside the bounding box or press Enter to crop the selection. 4 A dialog box informs you that the image file you are cropping will be changed on disk. Click OK. Every pixel in the
selected bitmap outside the bounding box is removed, but other objects in the image remain. 5 Preview the image and ensure that it meets your expectations. If not, select Edit > Undo Crop to revert to the
original image. Note: You can undo the effect of the Crop command (and revert to the original image file) up until the time that you quit Dreamweaver, or edit the file in an external image-editing application.
Optimize an image You can optimize images in your web pages from within Dreamweaver. 1 Open the page containing the image you want to optimize, select the image, and do either of the following:
• Click the Edit image settings button
in the image Property inspector.
• Select Modify > Image > Optimize. 2 Make your edits in the Image Preview dialog box and click OK.
Sharpen an image Sharpening increases the contrast of pixels around the edges of objects to increase the image’s definition or sharpness. 1 Open the page containing the image you want to sharpen, select the image, and do either of the following:
• Click the Sharpen button
in the image Property inspector.
• Select Modify > Image > Sharpen. 2 You can specify the degree of sharpening Dreamweaver applies to the image by dragging the slider control, or
entering a value between 0 and 10 in the text box. As you adjust the sharpness of the image using the Sharpness dialog box, you can preview the change to the image. 3 Click OK when you are satisfied with the image. 4 Save your changes by selecting File > Save, or revert to the original image by selecting Edit > Undo Sharpen.
Note: You can only undo the effect of the Sharpen command (and revert to the original image file) prior to saving the page containing the image. After you save the page, the changes made to the image are permanently saved.
Last updated 3/28/2012
231
USING DREAMWEAVER Adding content to pages
Adjust the brightness and contrast of an image Brightness/Contrast modifies the contrast or brightness of pixels in an image. This affects the highlights, shadows, and midtones of an image. You typically use Brightness/Contrast when correcting images that are too dark or too light. 1 Open the page containing the image you want to adjust, select the image, and do either of the following:
• Click the Brightness/Contrast
button in the image Property inspector.
• Select Modify > Image > Brightness/Contrast. 2 Drag the Brightness and Contrast sliders to adjust the settings. Values range from -100 to 100. 3 Click OK.
Create a rollover image You can insert rollover images in your page. A rollover is an image that, when viewed in a browser, changes when the pointer moves across it. You must have two images to create the rollover: a primary image (the image displayed when the page first loads) and a secondary image (the image that appears when the pointer moves over the primary image). Both images in a rollover should be the same size; if the images are not the same size, Dreamweaver resizes the second image to match the properties of the first image. Rollover images are automatically set to respond to the onMouseOver event. You can set an image to respond to a different event (for example, a mouse click) or change a rollover image. For a tutorial on creating rollovers, see www.adobe.com/go/vid0159. 1 In the Document window, place the insertion point where you want the rollover to appear. 2 Insert the rollover using one of these methods:
• In the Common category of the Insert panel, click the Images button and select the Rollover Image icon. With the Rollover Image icon displayed in the Insert panel, you can drag the icon to the Document window.
• Select Insert > Image Objects > Rollover Image. 3 Set the options and click OK. Image Name The name of the rollover image. Original image The image you want to display when the page loads. Enter the path in the text box, or click Browse and select the image. Rollover Image The image you want to display when the pointer rolls over the original image. Enter the path or click
Browse to select the image. Preload Rollover Image Preloads the images in the browser’s cache so no delay occurs when the user rolls the pointer
over the image. Alternate Text (Optional) Text to describe the image for viewers using a text-only browser. When clicked, Go to URL The file that you want to open when a user clicks the rollover image. Enter the path or click Browse and select the file.
Note: If you don’t set a link for the image, Dreamweaver inserts a null link (#) in the HTML source code to which the rollover behavior is attached. If you remove the null link, the rollover image will no longer work. 4 Select File > Preview in Browser or press F12. 5 In the browser, move the pointer over the original image to see the rollover image.
Last updated 3/28/2012
232
USING DREAMWEAVER Adding content to pages
Note: You cannot see the effect of a rollover image in Design view.
More Help topics “Apply the Swap Image behavior” on page 339 Rollover tutorial
Use an external image editor While in Dreamweaver, you can open a selected image in an external image editor; when you return to Dreamweaver after saving the edited image file, any changes you made to the image are visible in the Document window. You can set up Fireworks as your primary external editor. You can also set which file types an editor opens; and you can select multiple image editors. For example, you can set preferences to start Fireworks when you want to edit a GIF, and to start a different image editor when you want to edit a JPG or JPEG.
More Help topics “Working with Photoshop and Dreamweaver” on page 348 “Working with Fireworks and Dreamweaver” on page 343 “Start an external editor for media files” on page 245
Start the external image editor ❖ Do one of the following:
• Double-click the image you want to edit. • Right-click (Windows) or Control-click (Macintosh) the image you want to edit, then select Edit With > Browse and select an editor.
• Select the image you want to edit, and click Edit in the Property inspector. • Double-click the image file in the Files panel to start the primary image editor. If you haven’t specified an image editor, Dreamweaver starts the default editor for the file type. Note: When you open an image from the Files panel, the Fireworks integration features are not in effect; Fireworks does not open the original PNG file. To use the Fireworks integration features, open images from within the Document window. If you don’t see an updated image after returning to the Dreamweaver window, select the image and then click the Refresh button in the Property inspector.
Set an external image editor for an existing file type You can select an image editor for opening and editing graphic files. 1 Open the File Types/Editors Preferences dialog box by doing one of the following:
• Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh), and select File Types/Editors in the Category list on the left.
• Select Edit > Edit with External Editor and select File Types/Editors. 2 In the Extensions list, select the file extension you want to set an external editor for. 3 Click the Add (+) button above the Editors list. 4 In the Select External Editor dialog box, browse to the application you want to start as an editor for this file type.
Last updated 3/28/2012
233
USING DREAMWEAVER Adding content to pages
5 In the Preferences dialog box, click Make Primary if you want this editor to be the primary editor for this file type. 6 If you want to set up an additional editor for this file type, repeat steps 3 and 4.
Dreamweaver automatically uses the primary editor when you edit this image type. You can select the other listed editors from the context menu for the image in the Document window.
Add a new file type to the Extensions list 1 Open the File Types/Editors Preferences dialog box by doing one of the following:
• Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh), and select File Types/Editors in the Category list on the left.
• Select Edit > Edit with External Editor and select File Types/Editors. 2 In the File Types/Editors Preferences dialog box, click the Add (+) button above the Extensions list.
A text box appears in the Extensions list. 3 Type the file extension of the file type you want to start an editor for. 4 To select an external editor for the file type, click the Add (+) button above the Editors list. 5 In the dialog box that appears, select the application you want to use to edit this image type. 6 Click Make Primary if you want this editor to be the primary editor for the image type.
Change an existing editor preference 1 Open the File Types/Editors Preferences dialog box by doing one of the following:
• Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh), and select File Types/Editors in the Category list on the left.
• Select Edit > Edit with External Editor and select File Types/Editors. 2 In the File Types/Editors preferences dialog box, in the Extensions list select the file type you are changing to view
the existing editor(s). 3 In the Editors list, select the editor you want to want to affect, then do one of the following:
• Click the Add (+) or Delete (–) buttons above the Editors list to add or remove an editor. • Click the Make Primary button, to change which editor starts by default for editing.
Applying behaviors to images You can apply any available behavior to an image or image hotspot. When you apply a behavior to a hotspot, Dreamweaver inserts the HTML source code into the area tag. Three behaviors apply specifically to images: Preload Images, Swap Image, and Swap Image Restore. Preload Images Loads images that do not appear on the page right away (such as those that will be swapped in with behaviors, AP elements, or JavaScript) into the browser cache. This prevents delays caused by downloading when it is time for the images to appear. Swap Image Swaps one image for another by changing the SRC attribute of the img tag. Use this action to create button
rollovers and other image effects (including swapping more than one image at a time). Swap Image Restore Restores the last set of swapped images to their previous source files. This action is automatically
added whenever you attach the Swap Image action to an object by default; you should never need to select it manually. You can also use behaviors to create more sophisticated navigation systems, such as jump menus.
Last updated 3/28/2012
234
USING DREAMWEAVER Adding content to pages
More Help topics “Insert a jump menu” on page 266 “Apply the Swap Image behavior” on page 339 “Apply the Preload Images behavior” on page 336
Adding video Embed videos in web pages (HTML5) HTML5 supports video and audio tags that allow users to play video and audio files in a browser, without an external plug-in or player. Dreamweaver supports code hints for adding video and audio tags. Live View renders the video, providing a preview of the video that you are embedding in the web page. Note: Although you can embed any video in your web page, Live View does not always render all videos. The audio and video tags are supported in Dreamweaver using the Apple QuickTime plug-in. In Windows, if the Apple QuickTime plugin is not installed, then the web page does not render the media content.
Inserting FLV files Insert FLV files You can easily add FLV video to your web pages without using the Flash authoring tool. You must have an encoded FLV file before you begin. Dreamweaver inserts a SWF component that displays the FLV file; when viewed in a browser, this component displays the selected FLV file, as well as a set of playback controls.
Dreamweaver gives you the following options for delivering FLV video to your site visitors: Progressive Download Video Downloads the FLV file to the site visitor’s hard disk and then plays it. Unlike traditional
“download and play” methods of video delivery, however, progressive download allows the video file to start playing before the download is complete.
Last updated 3/28/2012
235
USING DREAMWEAVER Adding content to pages
Streaming Video Streams the video content and plays it on a web page after a short buffer period that ensures smooth
play back. To enable streaming video on your web pages, you must have access to Adobe® Flash® Media Server. You must have an encoded FLV file before you can use it in Dreamweaver. You can insert video files created with two kinds of codecs (compression/decompression technologies): Sorenson Squeeze and On2. As with regular SWF files, when you insert an FLV file, Dreamweaver inserts code that detects whether the user has the correct version of Flash Player to view the video. If the user does not have the correct version, the page displays alternative content that prompts the user to download the latest version of Flash Player. Note: To view FLV files, users must have Flash Player 8 or later installed on their computers. If a user does not have the required version of Flash Player installed, but does have Flash Player 6.0 r65 or later installed, the browser displays a Flash Player express installer instead of the alternative content. If the user declines the express install, the page then displays the alternative content. For more information about working with video, visit the Video Technology Center at www.adobe.com/go/flv_devcenter. Insert an FLV file 1 Select Insert > Media > FLV. 2 In the Insert FLV dialog box, select Progressive Download or Streaming Video from the Video Type pop-up menu. 3 Complete the rest of the dialog box options and click OK.
Note: Microsoft Internet Information Server (IIS) does not process nested object tags. For ASP pages, Dreamweaver uses nested object/embed code instead of nested object code when inserting SWF or FLV files. Set options for progressive download video The Insert FLV dialog box lets you set options for progressive download delivery of an FLV file inserted in a web page. 1 Select Insert > Media > FLV (or click the FLV icon in the Media category of the Common insert bar). 2 In the Insert FLV dialog box, select Progressive Download Video from the Video Type menu. 3 Specify the following options: URL Specifies a relative or absolute path to the FLV file. To specify a relative path (for example, mypath/myvideo.flv), click the Browse button, navigate to the FLV file, and select it. To specify an absolute path, type the URL (for example, http://www.example.com/myvideo.flv) of the FLV file. Skin Specifies the appearance of the video component. A preview of the selected skin appears beneath the Skin popup menu. Width Specifies the width of the FLV file, in pixels. To have Dreamweaver determine the exact width of the FLV file,
click the Detect Size button. If Dreamweaver cannot determine the width, you must type a width value. Height Specifies the height of the FLV file, in pixels. To have Dreamweaver determine the exact height of the FLV file, click the Detect Size button. If Dreamweaver cannot determine the height, you must type a height value.
Note: Total With Skin is the width and height of the FLV file plus the width and height of the selected skin. Constrain Maintains the same aspect ratio between the width and height of the video component. This option is selected by default. Auto Play Specifies whether to play the video when the web page is opened. Auto Rewind Specifies whether the playback control returns to starting position after the video finishes playing.
4 Click OK to close the dialog box and add the FLV file to your web page.
Last updated 3/28/2012
236
USING DREAMWEAVER Adding content to pages
The Insert FLV command generates a video player SWF file and a skin SWF file that are used to display your video content on a web page. (To see the new files, you may need to click the Refresh button in the Files panel.) These files are stored in the same directory as the HTML file to which you’re adding video content. When you upload the HTML page containing the FLV file, Dreamweaver uploads these files as dependent files (as long as you click Yes in the Put Dependent Files dialog box). Set options for streaming video The Insert FLV dialog box lets you set options for streaming video download of an FLV file inserted in a web page. 1 Select Insert > Media > FLV (or click the FLV icon in the Media category of the Common insert bar). 2 Select Streaming Video from the Video Type pop-up menu. Server URI Specifies the server name, application name, and instance name in the form
rtmp://www.example.com/app_name/instance_name. Stream Name Specifies the name of the FLV file that you want to play (for example, myvideo.flv). The .flv extension
is optional. Skin Specifies the appearance of the video component. A preview of the selected skin appears beneath the Skin popup menu. Width Specifies the width of the FLV file, in pixels. To have Dreamweaver determine the exact width of the FLV file,
click the Detect Size button. If Dreamweaver cannot determine the width, you must type a width value. Height Specifies the height of the FLV file, in pixels. To have Dreamweaver determine the exact height of the FLV file, click the Detect Size button. If Dreamweaver cannot determine the height, you must type a height value.
Note: Total With Skin is the width and height of the FLV file plus the width and height of the selected skin. Constrain Maintains the same aspect ratio between the width and height of the video component. This option is selected by default. Live Video Feed Specifies whether the video content is live. If Live Video Feed is selected, Flash Player plays a live
video feed streamed from Flash® Media Server. The name of the live video feed is the name specified in the Stream Name text box. Note: When you select Live Video Feed, only the volume control appears on the component’s skin, because you cannot manipulate live video. Additionally, the Auto Play and Auto Rewind options have no effect. Auto Play Specifies whether to play the video when the web page is opened. Auto Rewind Specifies whether the playback control returns to starting position after the video finishes playing. Buffer Time Specifies the time, in seconds, required for buffering before the video starts playing. The default buffer time is set to 0 so that the video starts playing instantly after the Play button is clicked. (If Auto Play is selected, the video starts playing as soon as a connection is made with the server.) You might want to set a buffer time if you are delivering video that has a higher bit rate than the site visitor’s connection speed, or when Internet traffic might cause bandwidth or connectivity problems. For example, if you want to send 15 seconds of video to the web page before the web page starts to play the video, set the buffer time to 15.
3 Click OK to close the dialog box and add the FLV file to your web page.
The Insert FLV command generates a video player SWF file and a skin SWF file that are used to display your video on a web page. The command also generates a main.asc file that you must upload to your Flash Media Server. (To see the new files, you may need to click the Refresh button in the Files panel.) These files are stored in the same directory as the HTML file to which you’re adding video content. When you upload the HTML page containing the FLV file, don’t forget to upload the SWF files to your web server, and the main.asc file to your Flash Media Server.
Last updated 3/28/2012
237
USING DREAMWEAVER Adding content to pages
Note: If you already have a main.asc file on your server, check with your server administrator before uploading the main.asc file generated by the Insert FLV command. You can easily upload all of the required media files by selecting the video component placeholder in the Dreamweaver Document window, and clicking the Upload Media button in the Property inspector (Window > Properties). To see a list of required files, click Show required files. Note: The Upload Media button does not upload the HTML file that contains the video content. Edit Flash Player download information When you insert an FLV file in a page, Dreamweaver inserts code that detects whether the user has the correct version of Flash Player. If not, the page displays default alternative content that prompts the user to download the latest version. You can change this alternative content at any time. This procedure also applies to SWF files. Note: If a user does not have the required version but does have Flash Player 6.0 r65 or later, the browser displays a Flash Player express installer. If the user declines the express install, the page then displays the alternative content. 1 In the Design view of the Document window, select the SWF file or FLV file. 2 Click the eye icon in the tab of the SWF file or FLV file.
You can also press Control + ] to switch to alternative content view. To return to SWF/FLV view, press Control + [ until all of the alternative content is selected. Then press Control + [ again. 3 Edit the content just as you would edit any other content in Dreamweaver.
Note: You cannot add SWF files or FLV files as alternative content. 4 Click the eye icon again to return to the SWF or FLV file view.
Troubleshoot FLV files This section details some of the most common causes of problems with FLV files. Viewing problems caused by absence of related files The code generated by Dreamweaver CS4 and later relies on four dependent files, different from the FLV file itself:
• swfobject_modified.js • expressInstall.swf • FLVPlayer_Progressive.swf • The skin file (for example Clear_Skin_1.swf) Note that there are two more dependent files for Dreamweaver CS4 and later, compared to Dreamweaver CS3. The first two of these files (swfobject_modified.js and expressInstall.swf) are installed in a folder called Scripts, which Dreamweaver creates in the root of your site if it doesn't already exist. The second two files (FLVPlayer_Progressive.swf and the skin file) are installed in the same folder as the page in which the FLV is embedded. The skin file contains the controls for the FLV, and its name depends on the skin chosen in the options described in Dreamweaver Help. For example, if you choose Clear Skin, the file is named Clear_Skin_1.swf. All four dependent files MUST be uploaded to your remote server for the FLV to display correctly. Forgetting to upload these files is the most common cause of FLV files failing to run correctly in a web page. If one of the files is missing, you might see a "white box" on the page.
Last updated 3/28/2012
238
USING DREAMWEAVER Adding content to pages
To ensure that you've uploaded all of the dependent files, use the Dreamweaver Files panel to upload the page in which the FLV appears. When you upload the page, Dreamweaver asks you if you want to upload dependent files (unless you've turned off this option). Click yes to upload dependent files. Viewing problems when previewing pages locally Because of security updates in Dreamweaver CS4, you cannot use the Preview in Browser command to test a page with an embedded FLV unless you define a local testing server in your Dreamweaver site definition and use the testing server to preview the page. Normally, you require a testing server only if you are developing pages with ASP, ColdFusion, or PHP (see “Set up your computer for application development” on page 504). If you are building websites that use only HTML, and haven't defined a testing server, pressing F12 (Windows) Opt+F12 (Macintosh) produces a jumble of skin controls onscreen. The workaround is either to define the testing server and use the testing server to preview your page, or upload your files to a remote server and view them there. Note: It’s possible that security settings may also be responsible for an inability to preview local FLV content, but Adobe has not been able to confirm this. You can try changing your security settings to see if it helps. For more information on changing your security settings, see Tech Note 117502. Other possible causes for problems with FLV files
• If you are having trouble previewing locally, make sure the Preview using temporary file option is deselected under Edit > Preferences > Preview in Browser
• Make sure you have the latest FlashPlayer plug-in • Be wary of moving files and folders around outside of Dreamweaver. When you move files and folders outside of Dreamweaver, Dreamweaver cannot guarantee the correct paths to FLV-related files.
• You can temporarily replace the FLV file that’s giving you trouble with a known working FLV file. If the replacement FLV file works, then the problem is with the original FLV file, and not with your browser or computer.
Edit or delete an FLV component Change the settings for the video on your web page, by selecting the video component placeholder in the Dreamweaver Document window and using the Property inspector. Another way is to delete the video component and reinsert it by selecting Insert > Media > FLV. Edit the FLV component 1 Select the video component placeholder in the Dreamweaver Document window by clicking the FLV icon at the center of the placeholder. 2 Open the Property inspector (Window > Properties) and make your changes.
Note: You cannot change video types (from progressive download to streaming, for example) by using the Property inspector. To change the video type, delete the FLV component, and reinsert it by selecting Insert > Media > FLV. Delete the FLV component ❖ Select the FLV component placeholder in the Dreamweaver Document window and press Delete.
Last updated 3/28/2012
239
USING DREAMWEAVER Adding content to pages
Remove FLV detection code For Dreamweaver CS4 and later, Dreamweaver inserts Flash Player detection code directly in the object tag that contains the FLV file. For Dreamweaver CS3 and earlier, however, the detection code resides outside the FLV file’s object tag. For this reason, if you want to delete FLV files from pages created with Dreamweaver CS3 and earlier, you must remove the FLV files and use the Remove FLV detection command to remove the detection code. ❖ Select Commands > Remove Flash Video Detection.
Inserting SWF files About FLA, SWF, and FLV file types Before you use Dreamweaver to insert content created with Adobe Flash, you should be familiar with the following different file types: FLA file (.fla) The source file for any project and created in the Flash authoring tool. This type of file can only be opened in Flash (not in Dreamweaver or in browsers). You can open the FLA file in Flash, then publish it as a SWF or SWT file to use in browsers. SWF file (.swf) A compiled version of the FLA (.fla) file, optimized for viewing on the web. This file can be played back
in browsers and previewed in Dreamweaver, but cannot be edited in Flash. FLV file (.flv) A video file that contains encoded audio and video data for delivery through Flash® Player. For example,
if you had a QuickTime or Windows Media video file, you would use an encoder (such as Flash® Video Encoder, or Sorensen Squeeze) to convert the video file to an FLV file. For more information, visit the Video Technology Center at www.adobe.com/go/flv_devcenter.
More Help topics “Working with Flash and Dreamweaver” on page 357 “Inserting FLV files” on page 234
Insert and preview SWF files Use Dreamweaver to add SWF files to your pages, and then preview them in a document or a browser. You can also set properties for SWF files in the Property inspector. For a tutorial on adding SWF files to web pages, see www.adobe.com/go/vid0150.
More Help topics “Working with Flash and Dreamweaver” on page 357 “Edit a SWF file from Dreamweaver in Flash” on page 357 SWF files and DHTML layers “Insert Shockwave movies” on page 247 “Inserting FLV files” on page 234 Working with Flash tutorial
Last updated 3/28/2012
240
USING DREAMWEAVER Adding content to pages
Insert a SWF file 1 In the Design view of the Document window, place the insertion point where you want to insert the content, then
do one of the following:
• In the Common category of the Insert panel, select Media and click the SWF icon
.
• Select Insert > Media > SWF. 2 In the dialog box that appears, select a SWF file (.swf).
A SWF file placeholder appears in the Document window.
The placeholder has a tabbed blue outline. The tab indicates the type of asset (SWF file) and the ID of the SWF file. The tab also displays an eye icon. It acts as toggle between the SWF file and the download information users see when they don’t have the correct version of Flash Player. 3 Save the file.
Dreamweaver informs you that two dependent files, expressInstall.swf and swfobject_modified.js, are being saved to a Scripts folder in your site. Don’t forget to upload these files when you upload the SWF file to your web server. Browsers can’t display the SWF file properly unless you have also uploaded these dependent files. Note: Microsoft Internet Information Server (IIS) does not process nested object tags. For ASP pages, Dreamweaver uses nested object/embed code instead of nested object code when inserting SWF or FLV files.
Edit Flash Player download information When you insert a SWF file in a page, Dreamweaver inserts code that detects whether the user has the correct version of Flash Player. If not, the page displays default alternative content that prompts the user to download the latest version. You can change this alternative content at any time. This procedure also applies to FLV files. Note: If a user does not have the required version but does have Flash Player 6.0 r65 or later, the browser displays a Flash Player express installer. If the user declines the express install, the page then displays the alternative content. 1 In the Design view of the Document window, select the SWF file or FLV file. 2 Click the eye icon in the tab of the SWF file or FLV file.
You can also press Control + ] to switch to alternative content view. To return to SWF/FLV view, press Control + [ until all of the alternative content is selected. Then press Control + [ again. 3 Edit the content just as you would edit any other content in Dreamweaver.
Note: You cannot add SWF files or FLV files as alternative content. 4 Click the eye icon again to return to the SWF (or FLV) file view.
Preview SWF files in the Document window 1 In the Document window, click the SWF file placeholder to select the content.
Last updated 3/28/2012
241
USING DREAMWEAVER Adding content to pages
2 In the Property inspector (Window > Properties), click the Play button. Click Stop to end the preview. You can also
preview the SWF file in a browser by pressing F12. To preview all SWF files in a page, press Control+Alt+Shift+P (Windows) or Command+Option+Shift+P (Macintosh). All SWF files are set to Play.
Set SWF file properties You can set properties for SWF files using the Property inspector. The properties are also applicable to Shockwave movies. ❖ Select a SWF file or a Shockwave movie and set the options in the Property inspector (Window > Properties). To
see all properties, click the expander arrow in the lower-right corner of the Property inspector. ID Specifies a unique ID for the SWF file. Enter an ID in the unlabeled text box on the far left side of the Property inspector. As of Dreamweaver CS4, a unique ID is required. W and H Specify the width and height of the movie, in pixels. File Specifies the path to the SWF file or Shockwave file. Click the folder icon to browse to a file, or type a path. Src Specifies the path to the source document (the FLA file), when Dreamweaver and Flash are both installed on your computer. To edit a SWF file, update the movie’s source document. Bg Specifies a background color for the movie area. This color also appears while the movie is not playing (while loading and after playing). Edit Starts Flash to update a FLA file (a file created in the Flash authoring tool). This option is disabled if you do not have Flash installed on your computer. Class Lets you apply a CSS class to the movie. Loop Makes the movie play continuously. When Loop is not selected, the movie plays once and stops. Autoplay Automatically plays the movie when the page loads. V Space and H Space Specifies the number of pixels of white space above, below, and on both sides of the movie. Quality Controls anti-aliasing during playback of the movie. High settings improve the appearance of movies.
However, at high settings movies require a faster processor to render correctly on the screen. Low favors speed over appearance, whereas High favors appearance over speed. Auto Low favors speed at first but improves appearance when possible. Auto High favors both qualities equally at first but later sacrifices appearance for speed if necessary. Scale Determines how the movie fits into the dimensions set in the width and height text boxes. The Default setting displays the entire movie. Align Determines how the movie is aligned on the page. Wmode Sets the Wmode parameter for the SWF file to avoid conflicts with DHTML elements, such as Spry widgets.
The default value is Opaque, which allows DHTML elements to appear on top of SWF files in a browser. If the SWF file includes transparencies and you want DHTML elements to appear behind them, select the Transparent option. Select the Window option to remove the Wmode parameter from the code and allow the SWF file to appear on top of other DHTML elements. Play Plays the movie in the Document window. Parameters Opens a dialog box for entering additional parameters to pass to the movie. The movie must be designed
to receive these additional parameters.
Last updated 3/28/2012
242
USING DREAMWEAVER Adding content to pages
Insert FlashPaper documents The Insert FlashPaper feature has been deprecated as of Dreamweaver CS5.
Adding web widgets A web widget is a web page component comprised of HTML, CSS, and JavaScript. Examples of web widgets include accordions, tabbed panels, and calendars. You can make your own personal selection of web widgets available in Dreamweaver by using the Adobe Widget Browser—an AIR application that lets you browse, configure, and preview widgets using a visual interface. 1 Select Insert > Widget. 2 In the Widget dialog box, select a widget and preset (if applicable) and click OK.
You can also add a web widget to a Dreamweaver page (CS5.5 and later) by doing the following: 1 In the Widget Browser, navigate to My Widgets. 2 Select the widget you want to add. 3 Click and hold the Drag and Drop in Dreamweaver icon at the upper left corner of the Live View tab. Drag the
widget to Dreamweaver into Design view (Windows) or Design or Code view (Macintosh OS). You cannot drag and drop the widget into Live view, but you can use Live view to test the widget once you’ve dropped it into the page.
More Help topics Adobe Widget Browser Help “Working with Spry widgets (general instructions)” on page 399
Adding Sound Audio file formats You can add sound to a web page. There are several different types of sound files and formats, including .wav, .midi, and .mp3. Some factors to consider before deciding on a format and method for adding sound are its purpose, your audience, file size, sound quality, and differences in browsers. Note: Sound files are handled very differently and inconsistently by different browsers. You may want to add a sound file to a SWF file and then embed the SWF file to improve consistency. The following list describes the more common audio file formats along with some of the advantages and disadvantages of each for web design. .midi or .mid (Musical Instrument Digital Interface) This format is for instrumental music. MIDI files are supported by
many browsers and don’t require a plug-in. Although their sound quality is very good, it can vary depending on a visitor’s sound card. A small MIDI file can provide a long sound clip. MIDI files cannot be recorded and must be synthesized on a computer with special hardware and software.
Last updated 3/28/2012
243
USING DREAMWEAVER Adding content to pages
.wav (Waveform Extension) These files have good sound quality, are supported by many browsers, and don’t require a plug-in. You can record your own WAV files from a CD, tape, microphone, and so on. However, the large file size severely limits the length of sound clips that you can use on your web pages. .aif (Audio Interchange File Format, or AIFF) The AIFF format, like WAV format, has good sound quality, can be played by most browsers, and doesn’t require a plug-in; you can also record AIFF files from a CD, tape, microphone, and so on. However, the large file size severely limits the length of sound clips that you can use on your web pages. .mp3 (Motion Picture Experts Group Audio, or MPEG-Audio Layer-3) A compressed format that makes sound files
substantially smaller. The sound quality is very good: if an mp3 file is recorded and compressed properly, its quality can rival that of a CD. mp3 technology lets you “stream” the file so that a visitor doesn’t have to wait for the entire file to download before hearing it. However, the file size is larger than a Real Audio file, so an entire song could still take quite a while to download over a typical dial-up (telephone line) modem connection. To play mp3 files, visitors must download and install a helper application or plug-in, such as QuickTime, Windows Media Player or RealPlayer. .ra, .ram, .rpm, or Real Audio This format has a high degree of compression, with smaller file sizes than mp3. Entire
song files can be downloaded in a reasonable amount of time. Because the files can be “streamed” from a normal web server, visitors can begin listening to the sound before the file has completely downloaded. Visitors must download and install the RealPlayer helper application or plug-in to play these files. .qt, .qtm, .mov or QuickTime This format is both an audio and video format developed by Apple Computer.
QuickTime is included with Apple Macintosh operating systems, and is used by most Macintosh applications that use audio, video, or animation. PCs can also play files in QuickTime format, but require a special QuickTime driver. QuickTime supports most encoding formats, including Cinepak, JPEG, and MPEG. Note: In addition to the more common formats listed above, there are many different audio and video file formats available for use on the web. If you encounter a media file format that you are unfamiliar with, locate the creator of the format for information on how best to use and deploy it.
More Help topics “Insert and edit media objects” on page 244
Link to an audio file Linking to an audio file is a simple and effective way to add sound to a web page. This method of incorporating sound files lets visitors choose whether they want to listen to the file, and makes the file available to the widest audience. 1 Select the text or image you want to use as the link to the audio file. 2 In the Property inspector, click the folder icon next to the Link text box to browse for the audio file, or type the file’s
path and name in the Link text box.
Embed a sound file Embedding audio incorporates the sound directly into the page, but the sound only plays if visitors to your site have the appropriate plug-in for the chosen sound file. Embed files if you want to use the sound as background music, or if you want to control the volume, the way the player looks on the page, or the beginning and ending points of the sound file.
Last updated 3/28/2012
244
USING DREAMWEAVER Adding content to pages
When incorporating sound files in your web pages, carefully consider their appropriate use in your web site, and how visitors to your site use these media resources. Always provide a control to either enable or disable the playing of the sound, in the event that visitors don’t want to listen to the audio content. 1 In Design view, place the insertion point where you want to embed the file and do one of the following:
• In the Common category of the Insert panel, click the Media button and select the Plugin icon
from the pop-up menu.
• Select Insert > Media > Plugin. 2 Browse for the audio file and click OK. 3 Enter the width and height by entering the values in the appropriate text boxes in the Property inspector or by
resizing the plug-in placeholder in the Document window. These values determine the size at which the audio controls are displayed in the browser.
Adding media objects Insert and edit media objects In addition to SWF and FLV files, you can insert QuickTime or Shockwave movies, Java applets, ActiveX controls, or other audio or video objects in a Dreamweaver document. If you inserted accessibility attributes with a media object, you can set the accessibility attributes and edit those values in the HTML code. 1 Place the insertion point in the Document window where you want to insert the object. 2 Insert the object by doing one of the following:
• In the Common category of the Insert panel, click the Media button and select the icon for the type of object you want to insert.
• Select the appropriate object from the Insert > Media submenu. • If the object you want to insert is not a Shockwave, Applet, or ActiveX object, select Plugin from the Insert > Media submenu. A dialog box appears letting you select a source file and specify certain parameters for the media object. To prevent such dialog boxes from appearing, select Edit > Preferences > General (Windows) or Dreamweaver > Preferences > General (Macintosh) and deselect the Show Dialog When Inserting Objects option. To override whatever preference is set for showing dialog boxes, hold down the Control (Windows) or Option (Macintosh) key while inserting the object. (For example, to insert a placeholder for a Shockwave movie without specifying the file, hold down Control or Option, and either click the Shockwave button in Media pop-up menu of the Common Insert panel, or select Insert > Media > Shockwave.) 3 Complete the Select File dialog box, and click OK.
Note: The Accessibility Attributes dialog box appears if you have chosen to show attributes when inserting media in the Edit > Preferences dialog box. 4 Set the accessibility attributes.
Note: You can also edit media object attributes by selecting the object and editing the HTML code in Code view, or rightclicking (Windows) or Control-clicking (Macintosh), and selecting Edit Tag Code. Title Enter a title for the media object.
Last updated 3/28/2012
245
USING DREAMWEAVER Adding content to pages
Access Key Enter a keyboard equivalent (one letter) in the text box to select the form object in the browser. This lets a
visitor to the site use the Control key (Windows) with the Access Key to access the object. For example, if you enter B as the Access Key, use Control+B to select the object in the browser. Tab Index Enter a number for the tab order of the form object. Setting a tab order is useful when you have other links and form objects on the page and need the user to tab through them in a specific order. If you set tab order for one object, be sure to set the tab order for all of them.
5 Click OK to insert the media object.
Note: If you click Cancel, a media object placeholder appears in the document, but Dreamweaver does not associate accessibility tags or attributes with it. To specify a source file, or to set dimensions and other parameters and attributes, use the Property inspector for each object. You can edit accessibility attributes for an object.
More Help topics “Optimize the work space for accessible page design” on page 653
Start an external editor for media files You can start an external editor from Dreamweaver to edit most media files. You can also specify the editor you want Dreamweaver to start to edit the file. 1 Make sure the media file type is associated to an editor on your system.
To find out what editor is associated with the file type, select Edit > Preferences in Dreamweaver and select File Types/Editors from the Category list. Click the file’s extension in the Extensions column to view the associated editor or editors in the Editors column. You can change the editor associated to a file type. 2 Double-click the media file in the Files panel to open it in the external editor.
The editor that starts when you double-click the file in the Files panel is called the primary editor. If you double-click an image file, for example, Dreamweaver opens the file in the primary external image editor such as Adobe Fireworks. 3 If you don’t want to use the primary external editor to edit the file, you can use another editor on your system to
edit the file by doing one of the following:
• In the Files panel, right-click (Windows) or Control-click (Macintosh) the filename and select Open With from the context menu.
• In Design view, right-click (Windows) or Control-click (Macintosh) the media element within the current page, and select Edit With from the context menu.
Specify the editor to start from Dreamweaver You can specify the editor you want Dreamweaver to use for editing a file type, and add or delete file types that Dreamweaver recognizes.
Explicitly specify which external editors should be started for a given file type 1 Select Edit > Preferences and select File Types/Editors from the Category list.
Filename extensions, such as .gif, .wav, and .mpg, are listed on the left under Extensions. Associated editors for a selected extension are listed on the right under Editors.
Last updated 3/28/2012
246
USING DREAMWEAVER Adding content to pages
2 Select the file type extension in the Extensions list and do one of the following:
• To associate a new editor with the file type, click the Plus (+) button above the Editors list and complete the dialog box that appears. For example, select the application icon for Acrobat to associate it with the file type.
• To make an editor the primary editor for a file type (that is, the editor that opens when you double-click the file type in the Files panel), select the editor in the Editors list and click Make Primary.
• To dissociate an editor from a file type, select the editor in the Editors list and click the Minus (-) button above the Editors list.
Add a new file type and associated editor 1 Click the Plus (+) button above the Extensions list and enter a file type extension (including the period at the
beginning of the extension) or several related extensions separated by spaces. For example, you might enter .xml .xsl if you wanted to associate them with an XML editor installed on your system. 2 Select an editor for the file type by clicking the Plus (+) button above the Editors list and completing the dialog box
that appears.
Remove a file type ❖ Select the file type in the Extensions list and click the Minus (-) button above the Extensions list.
Note: You can’t undo after removing a file type, so be sure that you want to remove it.
Use Design Notes with media objects As with other objects in Dreamweaver, you can add Design Notes to a media object. Design Notes are notes associated with a particular file, that are stored in a separate file. You can use Design Notes to keep track of extra file information associated with your documents, such as image source filenames and comments on file status. 1 Right-click (Windows) or Control-click (Macintosh) the object in the Document window.
Note: You must define your site before adding Design Notes to any object. 2 Select Design Notes for Page from the context menu. 3 Enter the information you want in the Design Note.
You can also add a Design Note to a media object from the Files panel by selecting the file, revealing the context menu, and choosing Design Notes from the context menu.
More Help topics “Enable and disable Design Notes for a site” on page 98 “Storing file information in Design Notes” on page 97
Last updated 3/28/2012
247
USING DREAMWEAVER Adding content to pages
Insert Shockwave movies You can use Dreamweaver to insert Shockwave movies into your documents. Adobe® Shockwave®, a standard for interactive multimedia on the web, is a compressed format that allows media files created in Adobe® Director® to be downloaded quickly and played by most popular browsers. 1 In the Document window, place the insertion point where you want to insert a Shockwave movie and do one of the
following:
• In the Common category of the Insert panel, click the Media button and select the Shockwave icon
from the
popup menu.
• Select Insert > Media > Shockwave. 2 In the dialog box that appears, select a movie file. 3 In the Property inspector, enter the width and height of the movie in the W and H text boxes.
More Help topics “Set SWF file properties” on page 241
Add video (non-FLV) You can add video to your web page in different ways and using different formats. Video can be downloaded to the user or it can be streamed so that it plays while it is downloading. 1 Place the clip in your site folder.
These clips are often in the AVI or MPEG file format. 2 Link to the clip or embed it in your page.
To link to the clip, enter text for the link such as “Download Clip”, select the text, and click the folder icon in the Property inspector. Browse to the video file and select it. Note: The user must download a helper application (a plug-in) to view common streaming formats like Real Media, QuickTime, and Windows Media.
Insert plug-in content You can create content such as a QuickTime movie for a browser plug-in, and then use Dreamweaver to insert that content into an HTML document. Typical plug-ins include RealPlayer and QuickTime, while some content files include mp3s and QuickTime movies. You can preview movies and animations that rely on browser plug-ins directly in the Design view of the Document window. You can play all plug-in elements at one time to see how the page will look to the user, or you can play each one individually to ensure that you have embedded the correct media element. Note: You cannot preview movies or animations that rely on ActiveX controls. After inserting content for a plug-in, use the Property inspector to set parameters for that content. To view the following properties in the Property inspector, select a plug-in object. The Property inspector initially displays the most commonly used properties. Click the expander arrow in the lowerright corner to see all properties.
Last updated 3/28/2012
248
USING DREAMWEAVER Adding content to pages
Insert plug-in content and set its properties 1 In the Design view of the Document window, place the insertion point where you want to insert the content, then
do one of the following:
• In the Common category of the Insert panel, click the Media button and select the Plugin icon
from the menu.
• Select Insert > Media > Plugin. 2 In the dialog box that appears, select a content file for a plug-in and click OK. 3 Set the plug-in options in the Property inspector. Name Specifies a name to identify the plug-in for scripting. Enter a name in the unlabeled text box on the far left side
of the Property inspector. W and H Specify, in pixels, the width and height allocated to the object on the page. Src Specifies the source data file. Click the folder icon to browse to a file, or enter a filename. Plg Url Specifies the URL of the pluginspace attribute. Enter the complete URL of the site where users can download
the plug-in. If the user viewing your page does not have the plug-in, the browser tries to download it from this URL. Align Determines how the object is aligned on the page. V Space and H Space Specify the amount of white space in pixels above, below, and on both sides of the plug-in. Border Specifies the width of the border around the plug-in. Parameters Opens a dialog box for entering additional parameters to pass to the plug-in. Many plug-ins respond to
special parameters. You can also view the attributes assigned to the selected plug-in by clicking the Attribute button. You can edit, add, and delete attributes such as width and height in this dialog box.
Play plug-in content in the Document window 1 Insert one or more media elements using one of the methods described in the previous section. 2 Do one of the following:
• Select one of the media elements you have inserted, and select View > Plugins > Play or click the Play button in the Property inspector.
• Select View > Plugins > Play All to play all of the media elements on the selected page that rely on plug-ins. Note: Play All only applies to the current document; it does not apply to other documents in a frameset, for example.
Stop playing plug-in content ❖ Select a media element and select View > Plugins >Stop, or click the Stop button in the Property inspector.
You can also select View > Plugins > Stop All to stop all plug-in content from playing.
Troubleshooting plug-ins If you have followed the steps to play plug-in content in the Document window, but some of the plug-in content does not play, try the following:
• Make sure the associated plug-in is installed on your computer, and that the content is compatible with the version of the plug-in you have.
Last updated 3/28/2012
249
USING DREAMWEAVER Adding content to pages
• Open the file Configuration/Plugins/UnsupportedPlugins.txt in a text editor and look to see if the problematic plug-in is listed. This file keeps track of plug-ins that cause problems in Dreamweaver and are therefore unsupported. (If you experience problems with a particular plug-in, consider adding it to this file.)
• Check that you have enough memory. Some plug-ins require an additional 2 to 5 MB of memory to run.
Insert an ActiveX control You can insert an ActiveX control in your page. ActiveX controls (formerly known as OLE controls) are reusable components, somewhat like miniature applications, that can act like browser plug-ins. They run in Internet Explorer with Windows, but they don’t run on the Macintosh browsers. The ActiveX object in Dreamweaver lets you supply attributes and parameters for an ActiveX control in your visitor’s browser. After inserting an ActiveX object, use the Property inspector to set attributes of the object tag and parameters for the ActiveX control. Click Parameters in the Property inspector to enter names and values for properties that don’t appear in the Property inspector. There is no widely accepted standard format for parameters for ActiveX controls; to find out which parameters to use, consult the documentation for the ActiveX control you’re using. ❖ In the Document window, place the insertion point where you want to insert the content and do one of the
following:
• In the Common category of the Insert panel, click the Media button and select the ActiveX icon
.
• In the Common category of the Insert panel, click the Media button and select the ActiveX icon. With the ActiveX icon displayed in the Insert panel, you can drag the icon to the Document window.
• Select Insert > Media > ActiveX. An icon marks where the ActiveX control will appear on the page in Internet Explorer.
ActiveX properties The Property inspector initially displays the most commonly used properties. Click the expander arrow in the lower-right corner to see all properties. Name Specifies a name to identify the ActiveX object for scripting. Enter a name in the unlabeled text box on the far
left side of the Property inspector. W and H Specify the width and height of the object, in pixels. Class ID Identifies the ActiveX control to the browser. Enter a value or select one from the pop-up menu. When the page is loaded, the browser uses the class ID to locate the ActiveX control required for the ActiveX object associated with the page. If the browser doesn’t locate the specified ActiveX control, it attempts to download it from the location specified in Base. Embed Adds an embed tag within the object tag for the ActiveX control. If the ActiveX control has another plug-in
equivalent, the embed tag activates the plug-in. Dreamweaver assigns the values you entered as ActiveX properties to their plug-in equivalents. Align Determines how the object is aligned on the page. Parameters Opens a dialog box for entering additional parameters to pass to the ActiveX object. Many ActiveX
controls respond to special parameters. Src Defines the data file to be used for a plug-in if the Embed option is turned on. If you don’t enter a value, Dreamweaver attempts to determine the value from the ActiveX properties entered already. V Space and H Space Specify the amount of white space, in pixels, above, below, and on both sides of the object.
Last updated 3/28/2012
250
USING DREAMWEAVER Adding content to pages
Base Specifies the URL containing the ActiveX control. Internet Explorer downloads the ActiveX control from this location if it has not been installed in the visitor’s system. If you don’t specify a Base parameter and if your visitor doesn’t already have the relevant ActiveX control installed, the browser can’t display the ActiveX object. Alt Img Specifies an image to be displayed if the browser doesn’t support the object tag. This option is available only
when the Embed option is deselected. Data Specifies a data file for the ActiveX control to load. Many ActiveX controls, such as Shockwave and RealPlayer, do not use this parameter.
Insert a Java applet You can insert a Java applet into an HTML document using Dreamweaver. Java is a programming language that allows the development of lightweight applications (applets) that can be embedded in web pages. After inserting a Java applet, use the Property inspector to set parameters. To view the following properties in the Property inspector, select a Java applet. 1 In the Document window, place the insertion point where you want to insert the applet, and then do one of the
following:
• In the Common category of the Insert panel, click the Media button and select the Applet icon
.
• Select Insert > Media > Applet. 2 Select a file containing a Java applet.
Java applet properties The Property inspector initially displays the most commonly used properties. Click the expander arrow in the lower-right corner to see all properties. Name Specifies a name to identify the applet for scripting. Enter a name in the unlabeled text box on the far left side
of the Property inspector. W and H Specify the width and height of the applet, in pixels. Code Specifies the file containing the applet’s Java code. Click the folder icon to browse to a file, or enter a filename. Base Identifies the folder containing the selected applet. When you select an applet, this text box is filled automatically. Align Determines how the object is aligned on the page. Alt Specifies alternative content (usually an image) to be displayed if the user’s browser doesn’t support Java applets
or has Java disabled. If you enter text, Dreamweaver inserts the text as the value of the applet’s alt attribute. If you select an image, Dreamweaver inserts an img tag between the opening and closing applet tags. V Space and H Space Specify the amount of white space in pixels above, below, and on both sides of the applet. Parameters Opens a dialog box for entering additional parameters to pass to the applet. Many applets respond to
special parameters.
Using behaviors to control media You can add behaviors to your page to start and stop various media objects. Control Shockwave Or Flash Play, stop, rewind, or go to a frame in a Shockwave movie or SWF file. Play Sound Lets you play a sound; for example, you can play a sound effect whenever the user moves the mouse
pointer over a link.
Last updated 3/28/2012
251
USING DREAMWEAVER Adding content to pages
Check Plugin Lets you check to see if visitors to your site have the required plug-in installed, then route them to
different URLs, depending on whether they have the right plug-in. This only applies to plug-ins, as the Check Plugin behavior does not check for ActiveX controls.
More Help topics “Apply the Control Shockwave or SWF behavior” on page 332 “Apply the Play Sound behavior” on page 336 “Apply the Check Plugin behavior” on page 332
Use parameters to control media objects Define special parameters to control Shockwave and SWF files, ActiveX controls, plug-ins, and Java applets. Parameters are used with the object, embed, and applet tags. Parameters set attributes specific to different types of objects. For example, a SWF file can use a quality parameter for the object tag. The Parameter dialog box is available from the Property inspector. See the documentation for the object you’re using for information on the parameters it requires. Note: There is no widely accepted standard for identifying data files for ActiveX controls. Consult the documentation for the ActiveX control you’re using to find out which parameters to use.
Enter a name and value for a parameter 1 Select an object that can have parameters (such as a Shockwave movie, an ActiveX control, a plug-in, or a Java
applet) in the Document window. 2 Open the dialog box using one of the following methods:
• Right-click (Windows) or Control-click (Macintosh) the object, and select Parameters from the context menu. • Open the Property inspector if it isn’t already open, and click the Parameters button found in the lower half of the Property inspector. (Make sure the Property inspector is expanded.) 3 Click the Plus (+) button and enter the parameter name and value in the appropriate columns.
Remove a parameter ❖ Select a parameter and press the minus (–) button.
Reorder parameters ❖ Select a parameter, and use the up and down arrow buttons.
Automating tasks Task automation The History panel records the steps you take when you complete a task. Automate a frequently performed task by replaying those steps from the History panel or creating a new command that performs the steps automatically.
Last updated 3/28/2012
252
USING DREAMWEAVER Adding content to pages
Certain mouse movements, such as selecting by clicking in the Document window, can’t be played back or saved. When you make such a movement, a black line appears in the History panel (the line does not become obvious until you perform another action). To avoid this, use the arrow keys instead of the mouse to move the insertion point within the Document window Some other steps also aren’t repeatable, such as dragging a page element to somewhere else on the page. When you perform such a step, an icon with a small red X appears in the History panel. Saved commands are retained permanently (unless you delete them), while recorded commands are discarded when you exit from Adobe® Dreamweaver® CS5, and copied sequences of steps are discarded when you copy something else
Use the History panel The History panel (Window > History) shows a list of the steps you’ve performed in the active document since you created or opened that document (but not steps you’ve performed in other frames, in other Document windows, or in the Site panel). Use the History panel to undo multiple steps at once and to automate tasks.
B A
C
D E
A. Slider (thumb) B. Steps C. Replay button D. Copy Steps button E. Save As Command button
The slider, or thumb, in the History panel initially points to the last step that you performed. Note: You can’t rearrange the order of steps in the History panel. Don’t think of the History panel as an arbitrary collection of commands; think of it as a way to view the steps you’ve performed, in the order in which you performed them.
Undo the last step ❖ Do one of the following:
• Select Edit > Undo. • Drag the History panel slider up one step in the list. Note: To scroll automatically to a particular step, you must click to the left of the step; clicking the step itself selects the step. Selecting a step is different from going back to that step in your undo history.
Undo multiple steps at once ❖ Drag the slider to point to any step, or click to the left of a step along the path of the slider.
The slider scrolls automatically to that step, undoing steps as it scrolls. Note: As with undoing a single step, if you undo a series of steps and then do something new in the document, you can no longer redo the undone steps; they disappear from the History panel.
Last updated 3/28/2012
253
USING DREAMWEAVER Adding content to pages
Set the number of steps that the History panel retains and shows The default number of steps is sufficient for most users’ needs. The higher the number, the more memory the History panel requires, which can affect performance and slow your computer significantly. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select General from the Category list on the left. 3 Enter a number for Maximum Number Of History Steps.
When the History panel reaches this maximum number of steps, the earliest steps are discarded.
Erase the history list for the current document: ❖ In the History panel’s context menu, select Clear History.
This command also clears all undo information for the current document; after choosing Clear History, you can’t undo the steps that are cleared. Clear History does not undo steps; it merely removes the record of those steps from memory.
Repeat steps Use the History panel to repeat the last step you performed, repeat a series of adjacent steps, or repeat a series of nonadjacent steps. Replay the steps directly from the History panel.
Repeat one step ❖ Do one of the following:
• Select Edit > Redo. • In the History panel, select a step and click the Replay button. The step is replayed and a copy of it appears in the History panel.
Repeat a series of steps 1 Select steps in the History panel:
• To select adjacent steps, drag from one step to another (don’t drag the slider; just drag from the text label of one step to the text label of another step), or select the first step, and then Shift-click the last step.
• To select nonadjacent steps, select a step, and then Control-click (Windows) or Command-click (Macintosh) to select or deselect other steps. The steps played are the selected (highlighted) steps, not necessarily the step the slider currently points to. Note: Although you can select a series of steps that includes a black line indicating a step that can’t be recorded, that step is skipped when you replay the steps. 2 Click Replay.
The steps are replayed in order, and a new step, Replay Steps, appears in the History panel.
Make or extend a selection ❖ Hold down the Shift key while pressing an arrow key.
If a black mouse-movement indicator line appears while you’re performing a task you want to repeat later, you can undo back to before that step and try another approach, perhaps using the arrow keys.
Last updated 3/28/2012
254
USING DREAMWEAVER Adding content to pages
Apply steps in the History panel to objects You can apply a set of steps from the History panel to any object in the Document window. If you select multiple objects and then apply steps to them from the History panel, the objects are treated as a single selection and Dreamweaver attempts to apply the steps to that combined selection; however, you can apply a set of steps only to a single object at a time. To apply the steps to each object in a set of objects, you must make the last step in the series select the next object in the set. The second procedure demonstrates this principle in a specific scenario: setting the vertical and horizontal spacing of a series of images.
Apply steps to one other object 1 Select the object. 2 Select the relevant steps in the History panel, and click Replay.
Apply steps to multiple objects 1 Start with a document in which each line consists of a small image (such as a graphical bullet or an icon) followed
by text. The goal is to set the images off from the text and from the other images above and below them.
2 Open the Property inspector (Window > Properties), if it isn’t already open. 3 Select the first image. 4 In the Property inspector, enter numbers in the V Space and H Space boxes to set the image’s spacing. 5 Click the image again to make the Document window active without moving the insertion point. 6 Press the Left Arrow key to move the insertion point to the left of the image. 7 Press the Down Arrow key to move the insertion point down one line, leaving it just to the left of the second image
in the series. 8 Press Shift+Right Arrow to select the second image.
Note: Do not select the image by clicking it, or you won’t be able to replay all the steps. 9 In the History panel, select the steps that correspond to changing the image’s spacing and selecting the next image.
Click Replay to replay those steps.
Last updated 3/28/2012
255
USING DREAMWEAVER Adding content to pages
The current image’s spacing changes, and the next image is selected.
10 Continue to click Replay until all the images are spaced correctly.
Copy and paste steps between documents Each open document has its own history of steps. You can copy steps from one document and paste them into another. Closing a document clears its history. If you know you will want to use steps from a document later, copy or save the steps before you close the document. 1 In the document containing the steps you want to reuse, select the steps in the History panel. 2 Click Copy Steps in the History panel
.
Note: The Copy Steps button in the History panel is different from the Copy command in the Edit menu. You can’t use Edit > Copy to copy steps, although you do use Edit > Paste to paste them. Be careful when you copy steps that include a Copy or a Paste command:
• Don’t use Copy Steps if one of the steps is a Copy command; you may not be able to paste such steps the way you want. • If your steps include a Paste command, you can’t paste those steps, unless the steps also include a Copy command before the Paste command. 3 Open the other document. 4 Place the insertion point where you want it, or select an object to apply the steps to. 5 Select Edit > Paste.
The steps are played back as they’re pasted into the document’s History panel. The History panel shows them as only one step, called Paste Steps. If you pasted steps into a text editor or into Code view or the Code inspector, they appear as JavaScript code. This can be useful for learning to write your own scripts.
More Help topics “Writing and editing code” on page 287
Create and use commands from history steps Save a set of history steps as a named command, which then becomes available in the Commands menu. Create and save a new command if you might use a set of steps again, especially the next time you start Dreamweaver.
Create a command 1 Select a step or set of steps in the History panel. 2 Click the Save As Command button, or select Save As Command from the History panel’s context menu. 3 Enter a name for the command and click OK.
The command appears in the Commands menu.
Last updated 3/28/2012
256
USING DREAMWEAVER Adding content to pages
Note: The command is saved as a JavaScript file (or sometimes an HTML file) in your Dreamweaver/Configuration/Commands folder. If you are using Dreamweaver on a multiuser operating system, the file is saved in the specific user’s Commands folder.
Use a saved command 1 Select an object to apply the command to, or place the insertion point where you want to apply the command. 2 Select the command from the Commands menu.
Edit a command name 1 Select Commands > Edit Command List. 2 Select a command to rename, enter a new name for it, and then click Close.
Delete a name from the Commands menu 1 Select Commands > Edit Command List. 2 Select a command. 3 Click Delete, and then click Close.
Record and save commands Record a temporary command for short-term use, or record and save a command to use later. Dreamweaver retains only one recorded command at a time; as soon as you start recording a new command, the old command is lost, unless you save it before recording the new command.
Temporarily record a series of steps 1 Select Commands > Start Recording, or press Control+Shift+X (Windows) or Command+Shift+X (Macintosh).
The pointer changes to indicate that you’re recording a command. 2 When you finish recording, select Commands > Stop Recording, or press Control+Shift+X (Windows) or
Command+Shift+X (Macintosh).
Play back a recorded command ❖ Select Commands > Play Recorded Command.
Save a recorded command 1 Select Commands > Play Recorded Command. 2 Select the Run Command step that appears in the History panel’s step list, and then click the Save As Command
button. 3 Enter a name for the command, and click OK.
The command appears in the Commands menu.
Last updated 3/28/2012
257
Chapter 9: Linking and navigation About linking and navigation About links After you’ve set up a Dreamweaver site to store your website documents and have created HTML pages, you’ll want to create connections from your documents to other documents. Dreamweaver provides several ways to create links to documents, images, multimedia files, or downloadable software. You can establish links to any text or image anywhere within a document, including text or images in a heading, list, table, absolutely-positioned element (AP element), or frame. There are several different ways of creating and managing links. Some web designers prefer to create links to nonexistent pages or files as they work, while others prefer to create all the files and pages first and then add the links. Another way to manage links is to create placeholder pages, in which you add and test links before completing all your site pages.
More Help topics “Test links in Dreamweaver” on page 266
Absolute, document-relative, and site root-relative paths Understanding the file path between the document you’re linking from and the document or asset you’re linking to is essential to creating links. Each web page has a unique address, called a Uniform Resource Locator (URL). However, when you create a local link (a link from one document to another on the same site), you generally don’t specify the entire URL of the document you’re linking to; instead, you specify a relative path from the current document or from the site’s root folder. There are three types of link paths:
• Absolute paths (such as http://www.adobe.com/support/dreamweaver/contents.html). • Document-relative paths (such as dreamweaver/contents.html). • Site root–relative paths (such as /support/dreamweaver/contents.html). Using Dreamweaver, you can easily select the type of document path to create for your links. Note: It is best to use the type of linking you prefer and are most comfortable with—either site root- or documentrelative. Browsing to links, as opposed to typing in the paths, ensures that you always enter the right path.
More Help topics “Set the relative path of new links” on page 262 “Working with Dreamweaver sites” on page 34
Last updated 3/28/2012
258
USING DREAMWEAVER Linking and navigation
Absolute paths Absolute paths provide the complete URL of the linked document, including the protocol to use (usually http:// for web pages), for example, http://www.adobe.com/support/dreamweaver/contents.html. For an image asset, the complete URL might be something like http://www.adobe.com/support/dreamweaver/images/image1.jpg. You must use an absolute path to link to a document or asset on another server. You can also use absolute paths for local links (to documents in the same site), but that approach is discouraged—if you move the site to another domain, all of your local absolute-path links will break. Using relative paths for local links also provides greater flexibility if you need to move files within your site. Note: When inserting images (not links), you can use an absolute path to an image on a remote server (that is, an image that is not available on the local hard drive).
Document-relative paths Document-relative paths are usually best for local links in most websites. They’re particularly useful when the current document and the linked document or asset are in the same folder and are likely to remain together. You can also use a document-relative path to link to a document or asset in another folder by specifying the path through the folder hierarchy from the current document to the linked document. The basic idea of document-relative paths is to omit the part of the absolute path that is the same for both the current document and the linked document or asset, providing only the portion of the path that differs. For example, suppose you have a site with the following structure: my_site (root folder) support contents.html hours.html resources tips.html products catalog.html
index.html (home page)
• To link from contents.html to hours.html (both in the same folder), use the relative path hours.html. • To link from contents.html to tips.html (in the resources subfolder), use the relative path resources/tips.html. At each slash (/), you move down one level in the folder hierarchy.
• To link from contents.html to index.html (in the parent folder, one level above contents.html), use the relative path ../index.html. Two dots and a slash (../) moves you up one level in the folder hierarchy.
• To link from contents.html to catalog.html (in a different subfolder of the parent folder), use the relative path ../products/catalog.html. Here, ../ moves you up to the parent folder, and products/ moves you down to the products subfolder. When you move files as a group—for example, when you move an entire folder, so that all the files inside that folder retain the same relative paths to each other—you don’t need to update document-relative links between those files. However, when you move an individual file that contains document-relative links, or an individual file targeted by a document-relative link, you do need to update those links. (If you move or rename files using the Files panel, Dreamweaver updates all relevant links automatically.)
Last updated 3/28/2012
259
USING DREAMWEAVER Linking and navigation
Site root–relative paths Site root–relative paths describe the path from the site’s root folder to a document. You may want to use these paths if you are working on a large website that uses several servers, or one server that hosts several sites. However, if you are not familiar with this type of path, you may want to stick to document-relative paths. A site root–relative path begins with a leading forward slash, which stands for the root folder of the site. For example, /support/tips.html is a site root–relative path to a file (tips.html) in the support subfolder of the site’s root folder. A site root–relative path is often the best way to specify links if you frequently move HTML files from one folder to another in your website. When you move a document that contains site root–relative links, you don’t need to change the links since the links are relative to the site root, and not to the document itself; for example, if your HTML files use site root–relative links for dependent files (such as images), then if you move an HTML file, its dependent-file links are still valid. However, when you move or rename the documents targeted by site root–relative links, you must update those links, even if the documents’ paths relative to each other haven’t changed. For example, if you move a folder, you must update all site root–relative links to files in that folder. (If you move or rename files using the Files panel, Dreamweaver updates all relevant links automatically.)
Linking Linking files and documents Before creating a link, make sure you understand how absolute, document-relative, and site root–relative paths work. You can create several types of links in a document:
• A link to another document or to a file, such as a graphic, movie, PDF, or sound file. • A named anchor link, which jumps to a specific location in a document. • An e-mail link, which creates a new blank e-mail message with the recipient’s address already filled in. • Null and script links, which you use to attach behaviors to an object or to create a link that executes JavaScript code. You can use the Property inspector and the Point-To-File icon to create links from an image, an object, or text to another document or file. Dreamweaver creates the links to other pages in your site using document-relative paths. You can also tell Dreamweaver to create new links using site root–relative paths. Important: Always save a new file before creating a document-relative path; a document-relative path is not valid without a definite starting point. If you create a document-relative path before saving the file, Dreamweaver temporarily uses an absolute path beginning with file:// until the file is saved; when you save the file, Dreamweaver converts the file:// path to a relative path. For a tutorial on creating links, see www.adobe.com/go/vid0149.
More Help topics “Absolute, document-relative, and site root-relative paths” on page 257 Creating links tutorial
Last updated 3/28/2012
260
USING DREAMWEAVER Linking and navigation
Attaching JavaScript behaviors to links You can attach a behavior to any link in a document. Consider using the following behaviors when you insert linked elements into documents: Set Text Of Status Bar Determines the text of a message and displays it in the status bar at the lower left of the browser window. For example, you can use this behavior to describe the destination of a link in the status bar instead of showing the URL associated with it. Open Browser Window Opens a URL in a new window. You can specify the properties of the new window, including its name, size, and attributes (whether it is resizable, has a menu bar, and so on). Jump Menu Edits a jump menu. You can change the menu list, specify a different linked file, or change the browser location in which the linked document opens.
More Help topics “Applying built-in JavaScript behaviors” on page 331
Link to documents using the Property inspector You can use the Property inspector’s folder icon or Link box to create links from an image, an object, or text to another document or file. 1 Select text or an image in the Document window’s Design view. 2 Open the Property inspector (Window > Properties) and do one of the following:
• Click the folder icon
to the right of the Link box to browse to and select a file.
The path to the linked document appears in the URL box. Use the Relative To pop-up menu in the Select HTML File dialog box to make the path document-relative or root-relative, and then click Select. The type of path you select applies only to the current link. (You can change the default setting of the Relative To box for the site.)
• Type the path and filename of the document in the Link box. To link to a document in your site, enter a document-relative or site root–relative path. To link to a document outside your site, enter an absolute path including the protocol (such as http://). You can use this approach to enter a link for a file that hasn’t been created yet. 3 From the Target pop-up menu, select a location in which to open the document:
•
_blank loads the linked document in a new, unnamed browser window.
•
_parent loads the linked document in the parent frame or parent window of the frame that contains the link. If
the frame containing the link is not nested, then the linked document loads in the full browser window.
•
_self loads the linked document in the same frame or window as the link. This target is the default, so you usually don’t have to specify it.
•
_top loads the linked document in the full browser window, thereby removing all frames.
If all the links on your page will be set to the same target, you can specify this target once by selecting Insert > HTML > Head Tags > Base and selecting the target information. For information about targeting frames, see “Control frame content with links” on page 193.
More Help topics “Absolute, document-relative, and site root-relative paths” on page 257
Last updated 3/28/2012
261
USING DREAMWEAVER Linking and navigation
Link to documents using the Point-To-File icon 1 Select text or an image in the Document window’s Design view. 2 Create a link in one of two ways:
• Drag the Point-To-File icon
(target icon) at the right of the Link box in the Property inspector and point to a visible anchor in the current document, a visible anchor in another open document, an element that has a unique ID assigned to it, or a document in the Files panel.
• Shift-drag from the selection and point to a visible anchor in the current document, a visible anchor in another open document, an element that has a unique ID assigned to it, or a document in the Files panel. Note: You can link to another open document only if your documents are not maximized in the Document window. To tile documents, select Window > Cascade or Window > Tile. When you point to an open document, that document moves to the foreground of your screen while you are making your selection.
More Help topics “Link to a specific place in a document” on page 262
Add a link using the Hyperlink command The Hyperlink command lets you create a text link to an image, an object, or to another document or file. 1 Place the insertion point in the document where you want the link to appear. 2 Do one of the following to display the Insert Hyperlink dialog box:
• Select Insert > Hyperlink. • In the Common category of the Insert panel, click the Hyperlink button. 3 Enter the text of the link and, after Link, the name of the file to link to (or click the folder icon
to browse to the
file). 4 In the Target pop-up menu, select the window in which the file should open or type its name.
The names of all the frames you’ve named in the current document appear in the pop-up list. If you specify a frame that doesn’t exist, the linked page opens in a new window that has the name you specified. You can also select from the following reserved target names:
•
_blank loads the linked file into a new, unnamed browser window.
•
_parent loads the linked file into the parent frameset or window of the frame that contains the link. If the frame
containing the link is not nested, the linked file loads into the full browser window.
•
_self loads the linked file into the same frame or window as the link. This target is the default, so you usually don’t
need to specify it.
•
_top loads the linked file into the full browser window, thereby removing all frames.
5 In the Tab Index box, enter a number for the tab order. 6 In the Title box, enter a title for the link. 7 In the Access Key box, enter a keyboard equivalent (one letter) to select the link in the browser. 8 Click OK.
Last updated 3/28/2012
262
USING DREAMWEAVER Linking and navigation
Set the relative path of new links By default, Dreamweaver creates links to other pages in your site using document-relative paths. To use site root– relative path instead, you must first define a local folder in Dreamweaver by choosing a local root folder to serve as the equivalent of the document root on a server. Dreamweaver uses this folder to determine the site root–relative paths to files. 1 Select Site > Manage Sites. 2 In the Manage Sites dialog box, double-click your site in the list. 3 In the Site Setup dialog box, expand Advanced Settings and select the Local Info category. 4 Set the relative path of new links by selecting the Document or Site Root option.
Changing this setting will not convert the path of existing links after you click OK. The setting applies only to new links you create with Dreamweaver. Note: Content linked with a site root–relative path does not appear when you preview documents in a local browser unless you specify a testing server, or select the Preview Using Temporary File option in Edit > Preferences > Preview In Browser. This is because browsers don’t recognize site roots—servers do. A quick way to preview content linked with site root– relative paths is to put the file on a remote server, then select File > Preview In Browser. 5 Click Save.
The new path setting applies only to the current site.
More Help topics “Absolute, document-relative, and site root-relative paths” on page 257 “Working with Dreamweaver sites” on page 34
Link to a specific place in a document You can use the Property inspector to link to a particular section of a document by first creating named anchors. Named anchors let you set markers in a document, which are often placed at a specific topic or at the top of a document. You can then create links to these named anchors, which quickly take your visitor to the specified position. Creating a link to a named anchor is a two-step process. First, you create a named anchor; then you create a link to the named anchor. Note: You can’t place a named anchor in an absolutely-positioned element (AP element).
Create a named anchor 1 In the Document window’s Design view, place the insertion point where you want the named anchor. 2 Do one of the following:
• Select Insert > Named Anchor. • Press Control+Alt+A (Windows) or Command+Option+A (Macintosh). • In the Common category of the Insert panel, click the Named Anchor button. 3 In the Anchor Name box, type a name for the anchor, and click OK. (The anchor name can’t contain spaces).
The anchor marker appears at the insertion point. Note: If you do not see the anchor marker, select View > Visual Aids > Invisible Elements.
Last updated 3/28/2012
263
USING DREAMWEAVER Linking and navigation
Link to a named anchor 1 In the Document window’s Design view, select text or an image to create a link from. 2 In the Link box of the Property inspector, type a number sign (#) and the name of the anchor. For example, to link
to an anchor named “top” in the current document, type #top. To link to an anchor named “top” in a different document in the same folder, type filename.html#top. Note: Anchor names are case-sensitive.
Link to a named anchor using the Point-To-File method 1 Open the document containing the named anchor.
Note: If you don’t see the anchor, select View > Visual Aids > Invisible Elements to make it visible. 2 In the Document window’s Design view, select text or an image you want to link from. (If this is another open
document, you must switch to it.) 3 Do one of the following:
• Click the Point-To-File icon
(target icon) to the right of the Link box in the Property inspector and drag it to the anchor you want to link to: either an anchor within the same document or an anchor in another open document.
• Shift-drag in the Document window from the selected text or image to the anchor you want to link to: either an anchor within the same document or an anchor in another open document.
Create an e-mail link An e-mail link opens a new blank message window (using the mail program associated with the user’s browser) when clicked. In the e-mail message window, the To box is automatically updated with the address specified in the e-mail link.
Create an e-mail link using the Insert Email Link command 1 In the Document window’s Design view, position the insertion point where you want the e-mail link to appear, or
select the text or image you want to appear as the e-mail link. 2 Do one of the following to insert the link:
• Select Insert > Email Link. • In the Common category of the Insert panel, click the Email Link button. 3 In the Text box, type or edit the body of the e-mail. 4 In the Email box, type the e-mail address, then click OK.
Create an e-mail link using the Property inspector 1 Select text or an image in the Document window’s Design view. 2 In the Link box of the Property inspector, type mailto: followed by an e-mail address.
Do not type any spaces between the colon and the e-mail address.
Auto-populate the subject line of an e-mail 1 Create an e-mail link using the Property inspector as outlined above. 2 In the Link box of the Property inspector, add ?subject= after the email, and type a subject after the equals sign.
Do not type any spaces between the question mark and the end of the e-mail address.
Last updated 3/28/2012
264
USING DREAMWEAVER Linking and navigation
The complete entry would look as follows: mailto:[email protected]?subject=Mail from Our Site
Create null and script links A null link is an undesignated link. Use null links to attach behaviors to objects or text on a page. For instance, you can attach a behavior to a null link so that it swaps an image or displays an absolutely-positioned element (AP element) when the pointer moves over the link. Script links execute JavaScript code or call a JavaScript function and are useful for giving visitors additional information about an item without leaving the current web page. Script links can also be used to perform calculations, validate forms, or do other processing tasks when a visitor clicks a specific item.
More Help topics “Apply a behavior” on page 329
Create a null link 1 Select text, an image, or an object in the Document window’s Design view. 2 In the Property inspector, type javascript:; (the word javascript, followed by a colon, followed by a semicolon)
in the Link box.
Create a script link 1 Select text, an image, or an object in the Document window’s Design view. 2 In the Link box of the Property inspector, type javascript: followed by some JavaScript code or a function call.
(Do not type a space between the colon and the code or call.)
Update links automatically Dreamweaver can update links to and from a document whenever you move or rename the document within a local site. This feature works best when you store your entire site (or an entire self-contained section of it) on your local disk. Dreamweaver does not change files in the remote folder until you put the local files on or check them in to the remote server. To make the updating process faster, Dreamweaver can create a cache file in which to store information about all the links in your local folder. The cache file is updated invisibly as you add, change, or delete links on your local site.
Enable automatic link updates 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 In the Preferences dialog box, select General from the category list on the left. 3 In the Document Options section of the General preferences, select an option from the Update Links When Moving
Files pop-up menu. Always Automatically updates all links to and from a selected document whenever you move or rename it. Never Does not automatically update all links to and from a selected document when you move or rename it. Prompt Displays a dialog box that lists all the files affected by the change. Click Update to update the links in these files, or click Don’t Update to leave the files unchanged.
Last updated 3/28/2012
265
USING DREAMWEAVER Linking and navigation
4 Click OK.
Create a cache file for your site 1 Select Site > Manage Sites. 2 Select a site, and then click Edit. 3 In the Site Setup dialog box, expand Advanced Settings and select the Local Info category. 4 In the Local Info category, select Enable Cache.
The first time you change or delete links to files in your local folder after starting Dreamweaver, Dreamweaver prompts you to load the cache. If you click Yes, Dreamweaver loads the cache and updates all the links to the file you just changed. If you click No, the change is noted in the cache, but Dreamweaver does not load the cache or update links. It may take a few minutes to load the cache on larger sites because Dreamweaver must determine whether the cache is up to date by comparing the timestamps of the files on the local site against the timestamps recorded in the cache. If you have not changed any files outside Dreamweaver, you can safely click the Stop button when it appears.
Re-create the cache ❖ In the Files panel, select Site > Advanced > Recreate Site Cache.
Change a link sitewide In addition to having Dreamweaver update links automatically whenever you move or rename a file, you can manually change all links (including e-mail, FTP, null, and script links) so that they point somewhere else. This option is most useful when you want to delete a file that other files link to, but you can use it for other purposes. For example, suppose you link the words “this month’s movies” to /movies/july.html throughout your site. On August 1 you would change those links so that they point to /movies/august.html. 1 Select a file in the Local view of the Files panel.
Note: If you are changing an e-mail, FTP, null, or script link, you do not need to select a file. 2 Select Site > Change Link Sitewide. 3 Complete these options in Change Link Sitewide dialog box: Change All Links To Click the folder icon
to browse to and select the target file from which to unlink. If you are changing an e-mail, FTP, null, or script link, type the full text of the link you are changing. Into Links to Click the folder icon
to browse to and select the new file to link to. If you are changing an e-mail, FTP, null, or script link, type the full text of the replacement link. 4 Click OK.
Dreamweaver updates any documents that link to the selected file, making them point to the new file, using the path format already used in the document (for example, if the old path was document-relative, the new path is also document-relative). After you change a link sitewide, the selected file becomes an orphan (that is, no files on your local disk point to it). You can safely delete it without breaking any links in your local Dreamweaver site. Important: Because these changes occur locally, you must manually delete the corresponding orphan file in the remote folder and put or check in any files in which links were changed; otherwise, visitors to your site won’t see the changes.
Last updated 3/28/2012
266
USING DREAMWEAVER Linking and navigation
Test links in Dreamweaver Links are not active within Dreamweaver; that is, you cannot open a linked document by clicking the link in the Document window. ❖ Do one of the following:
• Select the link and select Modify > Open Linked Page. • Press Control (Windows) or Command (Macintosh) and double-click the link. Note: The linked document must reside on your local disk.
More Help topics “Find broken, external, and orphaned links” on page 270 “Fix broken links” on page 271
Jump menus About jump menus A jump menu is a pop-up menu in a document, visible to your site visitors, listing links to documents or files. You can create links to documents in your website, links to documents on other websites, e-mail links, links to graphics, or links to any file type that can be opened in a browser. Each option in a jump menu is associated with a URL. When users choose an option, they are redirected (“jump”) to the associated URL. Jump menus are inserted within the Jump Menu form object. A jump menu can contain three components:
• (Optional) A menu selection prompt, such as a category description for the menu items, or instructions, such as “Choose one”.
• (Required) A list of linked menu items: a user selects an option and a linked document or file opens. • (Optional) A Go button.
More Help topics “Apply the Jump Menu behavior” on page 335 “Apply the Jump Menu Go behavior” on page 335
Insert a jump menu 1 Open a document, and then place the insertion point in the Document window. 2 Do one of the following:
• Select Insert > Form > Jump Menu. • In the Forms category of the Insert panel, click the Jump Menu button. 3 Complete the Insert Jump menu dialog box and click OK. Here is a partial list of options: Plus and Minus buttons Click Plus to insert an item; click Plus again to add another one. To delete an item, select it
and click Minus.
Last updated 3/28/2012
267
USING DREAMWEAVER Linking and navigation
Arrow buttons Select an item and click the arrows to move it up or down in the list. Text Type the name of an unnamed item. If your menu includes a selection prompt (such as “Choose one”), type it
here as the first menu item (if so, you must also choose the Select First Item After URL Change option at the bottom). When Selected Go To URL Browse to the target file or type its path. Open URLs In Specify whether to open the file in the same window or in a frame. If the frame you want to target doesn’t appear in the menu, close the Insert Jump Menu dialog box and name the frame. Insert Go Button After Menu Select to insert a Go button rather than a menu selection prompt. Select First Item After URL Change Select if you inserted a menu selection prompt (“Choose one”) as the first menu item.
More Help topics “View and set frame properties and attributes” on page 190
Edit jump menu items You can change the order of items in the menu or the file an item links to, and you can add, delete, or rename an item. To change the location in which a linked file opens, or to add or change a menu selection prompt, you must apply the Jump Menu behavior from the Behaviors panel. 1 Open the Property inspector (Window > Properties) if it isn’t already open. 2 In the Document window’s Design view, click the jump menu object to select it. 3 In the Property inspector, click the List Values button. 4 Use the List Values dialog box to make your changes to the menu items, and then click OK.
More Help topics “Apply the Jump Menu behavior” on page 335
Troubleshooting jump menus After a user selects a jump menu item, there is no way to reselect that menu item if the user navigates back to that page, or if the Open URL In box specifies a frame. There are two ways to work around this problem:
• Use a menu selection prompt, such as a category, or a user instruction, such as “Choose one”. The menu selection prompt is reselected automatically after each menu selection.
• Use a Go button, which allows a user to revisit the currently chosen link. When you use a Go button with a jump menu, the Go button becomes the only mechanism that “jumps” the user to the URL associated with the selection in the menu. Selecting a menu item in the jump menu no longer re-directs the user automatically to another page or frame. Note: Select only one of these options per jump menu, in the Insert Jump Menu dialog box, because they apply to an entire jump menu.
Last updated 3/28/2012
268
USING DREAMWEAVER Linking and navigation
Navigation bars About navigation bars The navigation bar feature has been deprecated as of Dreamweaver CS5. Adobe recommends using the Spry Menu Bar widget if you want to create a navigation bar.
More Help topics “Working with the Spry Menu Bar widget” on page 404
Image maps About image maps An image map is an image that has been divided into regions called hotspots; when a user clicks a hotspot, an action occurs (for example, a new file opens). Client-side image maps store the hypertext link information in the HTML document—not in a separate map file as server-side image maps do. When a site visitor clicks a hotspot in the image, the associated URL is sent directly to the server. This makes client-side image maps faster than server-side image maps, because the server does not need to interpret where the visitor clicked. Client-side image maps are supported by Netscape Navigator 2.0 and later versions, NCSA Mosaic 2.1 and 3.0, and all versions of Internet Explorer. Dreamweaver does not alter references to server-side image maps in existing documents; you can use both client-side image maps and server-side image maps in the same document. However, browsers that support both types of image maps give priority to client-side image maps. To include a server-side image map in a document, you must write the appropriate HTML code.
Insert client-side image maps When you insert a client-side image map, you create a hotspot area and then define a link that opens when a user clicks the hotspot area. Note: You can create multiple hotspot areas, but they are part of the same image map. 1 In the Document window, select the image. 2 In the Property inspector, click the expander arrow in the lower-right corner to see all properties. 3 In the Map Name box, enter a unique name for the image map. If you are using multiple image maps in the same
document, make sure each map has a unique name. 4 To define the image map areas, do one of the following:
• Select the circle tool • Select the rectangle tool
and drag the pointer over the image to create a circular hotspot. and drag the pointer over the image to create a rectangular hotspot.
• Select the polygon tool
and define an irregularly shaped hotspot by clicking once for each corner point. Click the arrow tool to close the shape.
After you create the hotspot, the hotspot Property inspector appears.
Last updated 3/28/2012
269
USING DREAMWEAVER Linking and navigation
5 In the hotspot Property inspector’s Link box, click the folder icon
to browse to and select the file you want to
open when the user clicks the hotspot, or type the path. 6 In the Target pop-up menu, select the window in which the file should open or type its name.
The names of all the frames you’ve named in the current document appear in the pop-up list. If you specify a frame that doesn’t exist, the linked page loads into a new window that has the name you specified. You can also select from the following reserved target names:
•
_blank loads the linked file into a new, unnamed browser window.
•
_parent loads the linked file into the parent frameset or window of the frame that contains the link. If the frame
containing the link is not nested, the linked file loads into the full browser window.
•
_self loads the linked file into the same frame or window as the link. This target is the default, so you usually don’t
need to specify it.
•
_top loads the linked file into the full browser window, thereby removing all frames.
Note: The target option isn’t available until the selected hotspot contains a link. 7 In the Alt box, type alternative text for display in text-only browsers or browsers that download images manually.
Some browsers display this text as a tooltip when the user moves the pointer over the hotspot. 8 Repeat steps 4 through 7 to define additional hotspots in the image map. 9 When you finish mapping the image, click a blank area in the document to change the Property inspector.
Modify image map hotspots You can easily edit the hotspots you create in an image map. You can move a hotspot area, resize hotspots, or move a hotspot forward or back in an absolutely-positioned element (AP element). You can also copy an image with hotspots from one document to another, or copy one or more hotspots from an image and paste them on another image; hotspots associated with the image are also copied to the new document.
Select multiple hotspots in an image map 1 Use the pointer hotspot tool to select a hotspot. 2 Do one of the following:
• Shift-click the other hotspots you want to select. • Press Control+A (Windows) or Command+A (Macintosh) to select all of the hotspots.
Move a hotspot 1 Use the pointer hotspot tool to select the hotspot. 2 Do one of the following:
• Drag the hotspot to a new area. • Use the Control + arrow keys to move a hotspot by 10 pixels in the selected direction. • Use the arrow keys to move a hotspot by 1 pixel in the selected direction.
Resize a hotspot 1 Use the pointer hotspot tool
to select the hotspot.
2 Drag a hotspot selector handle to change the size or shape of the hotspot.
Last updated 3/28/2012
270
USING DREAMWEAVER Linking and navigation
Troubleshooting links Find broken, external, and orphaned links Use the Check Links feature to search for broken links and orphaned files (files that still exist in the site but that aren’t linked to by any other files in the site). You can search an open file, a portion of a local site, or an entire local site. Dreamweaver verifies links only to documents within the site; Dreamweaver compiles a list of external links in the selected document or documents but does not verify them. You can also identify and delete files that are no longer used by other files in your site.
More Help topics “Identify and delete unused files” on page 75
Check links in the current document 1 Save the file to a location within your local Dreamweaver site. 2 Select File > Check Page > Links.
The Broken Links report appears in the Link Checker panel (in the Results panel group). 3 In the Link Checker panel, select External Links from the Show pop-up menu to view another report.
The External Links report appears in the Link Checker panel (in the Results panel group). You can check for orphaned files when you check links across an entire site. 4 To save the report, click the Save Report button in the Link Checker panel. The report is a temporary file; it will be
lost if you don’t save it.
Check links in part of a local site 1 In the Files panel, select a site from the Current Sites pop-up menu. 2 In Local view, select the files or folders to check. 3 Initiate the check by doing one of the following:
• Right-click (Windows) or Control-click (Macintosh) one of the selected files, and then select Check Links > Selected Files/Folders from the context menu.
• Select File > Check Page > Links. The Broken Links report appears in the Link Checker panel (in the Results panel group). 4 In the Link Checker panel, select External Links from the Show pop-up menu to view another report.
The External Links report appears in the Link Checker panel (in the Results panel group). You can check for orphaned files when you check links across an entire site. 5 To save a report, click the Save Report button in the Link Checker panel.
Check links across the entire site 1 In the Files panel, select a site from the Current Sites pop-up menu.
Last updated 3/28/2012
271
USING DREAMWEAVER Linking and navigation
2 Select Site > Check Links Sitewide.
The Broken Links report appears in the Link Checker panel (in the Results panel group). 3 In the Link Checker panel, select External Links or Orphaned Files from the Show pop-up menu to view another
report. A list of files that fit the report type you selected appears in the Link Checker panel. Note: If you select Orphaned Files as your report type, you can delete orphaned files from the Link Checker panel directly by selecting a file from the list and pressing the Delete key. 4 To save a report, click the Save Report button in the Link Checker panel.
Fix broken links After you run a links reports, you can fix broken links and image references directly in the Link Checker panel, or you can open files from the list and fix links in the Property inspector.
Fix links in the Link Checker panel 1 Run a link check report. 2 In the Broken Links column (not the Files column) of the Link Checker panel (in the Results panel group), select
the broken link. A folder icon appears next to the broken link. 3 Click the folder icon next
to the broken link and browse to the correct file, or type the correct path and
filename. 4 Press Tab or Enter (Windows) or Return (Macintosh).
If there are other broken references to this same file, you are prompted to fix the references in the other files as well. Click Yes to have Dreamweaver update all the documents on the list that reference this file. Click No to have Dreamweaver update the current reference only. Note: If Enable File Check In And Check Out is enabled for the site, Dreamweaver attempts to check out files that require changes. If it cannot check out a file, Dreamweaver displays a warning dialog box and leaves broken references unchanged.
Fix links in the Property inspector 1 Run a link check report. 2 In the Link Checker panel (in the Results panel group), double-click an entry in the File column.
Dreamweaver opens the document, selects the broken image or link, and highlights the path and filename in the Property inspector. (If the Property inspector is not visible, select Window > Properties to open it.) 3 To set a new path and filename in the Property inspector, click the folder icon
to browse to the correct file, or
type over the highlighted text. If you are updating an image reference and the new image appears at the incorrect size, click the W and H labels in the Property inspector or click the Refresh button to reset the height and width values. 4 Save the file.
As links are fixed, their entries disappear from the Link Checker list. If an entry still appears in the list after you enter a new path or filename in the Link Checker (or after you save changes in the Property inspector), Dreamweaver cannot find the new file and still considers the link broken.
Last updated 3/28/2012
272
Chapter 10: Previewing pages Previewing pages Design view gives you an idea of how your page will look on the web but does not render pages exactly as browsers do. Live view presents a more accurate depiction, and lets you work in Code view so that you can see changes to the design. The Preview in Browser feature lets you see how your pages will look in specific browsers.
Previewing pages in Dreamweaver About Live view Live view differs from the traditional Dreamweaver design view in that it provides a non-editable, more realistic rendering of what your page will look like in a browser. Live view does not replace the Preview in Browser command, but rather provides another way of seeing what your page looks like “live” without having to leave the Dreamweaver workspace. You can switch to Live view any time you are in Design view. Switching to Live view, however, is not related to switching between any of the other traditional views in Dreamweaver (Code/Split/Design). When you switch to Live view from Design view, you are simply toggling the Design view between editable and “live”. While Design view remains frozen once you enter Live view, Code view remains editable, so you can change your code, and then refresh Live view to see your changes take effect. When you’re in Live view, you have the additional option of viewing live code. Live Code view is like Live view in that it displays a version of the code that the browser is executing in order to render the page. Like Live view, Live Code view is a non-editable view. An additional advantage of Live view is the ability to freeze JavaScript. For example, you can switch to Live view and hover over Spry-based table rows that change color as the result of user interaction. When you freeze JavaScript, Live view freezes the page in its current state. You can then edit your CSS or JavaScript and refresh the page to see the changes take effect. Freezing JavaScript in Live view is useful if you want to see and change properties for the different states of pop-up menus or other interactive elements that you can’t see in traditional Design view. For a video overview from the Dreamweaver engineering team about working with Live View, see www.adobe.com/go/dw10liveview. For a video overview from the Dreamweaver engineering team about working with Live view navigation, see www.adobe.com/go/dwcs5livenav_en. For a video tutorial on working with Live View, related files, and the Code Navigator, see www.adobe.com/go/lrvid4044_dw.
Preview pages in Live view 1 Make sure that you are in Design view (View > Design) or Code and Design views (View > Code and Design). 2 Click the Live view button.
3 (Optional) Make your changes in Code view, in the CSS Styles panel, in an external CSS style sheet, or in another
related file.
Last updated 3/28/2012
273
USING DREAMWEAVER Previewing pages
Even though you can’t edit in Live view, your options for making edits in other areas (for example, in the CSS Styles panel or in Code view) change as you click in Live view. You can work with related files (such as CSS style sheets) while keeping Live view in focus by opening the related file from the Related Files toolbar at the top of the document. 4 If you’ve made changes in Code view or in a related file, refresh Live view by clicking the Refresh button in the
Document tool bar, or by pressing F5. 5 To return to the editable Design view, click the Live view button again.
Preview Live Code The code displayed in Live Code view is similar to what you would see if you viewed the page source from a browser. While such page sources are static, providing you with only the source of the page from the browser, Live Code view is dynamic, and updates as you interact with the page in Live view. 1 Make sure that you are in Live view. 2 Click the Live Code button.
Dreamweaver displays the live code that the browser would use to execute the page. The code is highlighted in yellow and is uneditable. When you interact with interactive elements on the page, Live Code highlights the dynamic changes in the code. 3 To turn off highlighting for changes in Live Code view, choose View > Live View Options > Highlight Changes in
Live Code. 4 To return to the editable Code view, click the Live Code button again.
To change Live Code preferences, choose Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh OS), and select the Code Coloring category.
Freeze JavaScript Do one of the following:
• Press F6 • Select Freeze JavaScript from the Live View button’s pop-up menu. An info bar at the top of the document tells you that JavaScript is frozen. To close the info bar, click the close link.
Live view options Besides the Freeze JavaScript option, there are some other options available from the Live View button’s pop-up menu, or from the View > Live View Options menu item. Freeze JavaScript Freezes elements affected by JavaScript in their current state. Disable JavaScript Disables JavaScript and re-renders the page as it would look if a browser did not have JavaScript
enabled. Disable Plug-ins Disables plug-ins and re-renders the page as it would look if a browser did not have plug-ins enabled. Highlight Changes in Live Code Turns highlighting for changes in Live Code off or on.
Last updated 3/28/2012
274
USING DREAMWEAVER Previewing pages
Edit the Live View Page in a New Tab Lets you open new tabs for site documents you browse to using the Browser Navigation toolbar or the Follow Link(s) feature. You must browse to the document first, then select Edit the Live View Page in a New Tab to create a new tab for it. Follow Link Makes the next link you click in Live View active. Alternatively you can Control-click a link in Live view
to make it active. Follow Links Continuously Makes links in Live View continuously active until you disable them again, or close the page. Automatically Sync Remote Files Automatically syncs the local and remote file when you click the Refresh icon in the Browser Navigation toolbar. Dreamweaver puts your file to the server before refreshing so that both files are in sync. Use Testing Server for Document Source Used mainly by dynamic pages (such as ColdFusion pages), and selected by
default for dynamic pages. When this option is selected, Dreamweaver uses the version of the file on the site’s testing server as the source for the Live view display. Use Local Files for Document Links The default setting for non-dynamic sites. When this option is selected for
dynamic sites that use a testing server, Dreamweaver uses the local versions of files that are linked to the document (for example, CSS and JavaScript files), instead of the files on the testing server. You can then make local changes to related files so that you can see how they look before putting them to the testing server. If this option is deselected, Dreamweaver uses the testing server versions of related files. HTTP Request Settings Takes you to an advanced settings dialog box where you can enter values for displaying live
data. For more information, click the Help button in the dialog box.
More Help topics “Browser Navigation toolbar overview” on page 10 “Switch between views in the Document window” on page 16 “Open Related Files” on page 66 “Viewing live data” on page 564 Live View video tutorial
Previewing pages in browsers Preview in a browser You can preview a page in a browser at any time; you don’t have to upload it to a web server first. When you preview a page, all browser-related functions should work, including JavaScript behaviors, document-relative and absolute links, ActiveX® controls, and Netscape Navigator plug-ins, provided that you installed the required plug-ins or ActiveX controls in your browsers. Before previewing a document, save the document; otherwise, the browser does not display your most recent changes. 1 Do one of the following to preview the page:
• Select File > Preview In Browser, and then select one of the listed browsers. Note: If no browsers are listed, select Edit > Preferences or Dreamweaver > Preferences (Macintosh), and then select the Preview In Browser category on the left to select a browser.
• Press F12 (Windows) or Option+F12 (Macintosh) to display the current document in the primary browser. • Press Control+F12 (Windows) or Command+F12 (Macintosh) to display the current document in the secondary browser.
Last updated 3/28/2012
275
USING DREAMWEAVER Previewing pages
2 Click links and test content in your page.
Note: Content linked with a site root-relative path does not appear when you preview documents in a local browser unless you specify a testing server, or select the Preview Using Temporary File option in Edit > Preferences > Preview In Browser. This is because browsers don’t recognize site roots—servers do. To preview content linked with root-relative paths, put the file on a remote server, and then select File > Preview In Browser to view it. 3 Close the page in the browser when you finish testing.
More Help topics “Site root–relative paths” on page 259
Set browser preview preferences You can set preferences for the browser to use when previewing a site and define default primary and secondary browsers. 1 Select File > Preview In Browser > Edit Browser List. 2 To add a browser to the list, click the Plus (+) button, complete the Add Browser dialog box, and then click OK. 3 To delete a browser from the list, select the browser, and then click the Minus (-) button. 4 To change settings for a selected browser, click the Edit button, make changes in the Edit Browser dialog box, and
then click OK. 5 Select the Primary Browser or the Secondary Browser option to specify whether the selected browser is the primary
or secondary browser. F12 (Windows) or Option+F12 (Macintosh) opens the primary browser; Control+F12 (Windows) or Command+F12 (Macintosh) opens the secondary browser. 6 Select Preview Using Temporary File to create a temporary copy for previewing and server debugging. (Deselect
this option if you want to update the document directly.)
Previewing pages in mobile devices To preview pages created in Dreamweaver on various mobile devices, use Device Central with its built-in Opera Small-Screen Rendering feature. Different devices have different browsers installed, but the preview can give a good impression of how content will look and behave on a selected device. 1 Start Dreamweaver. 2 Open a file. 3 Do one of the following:
• Select File > Preview in Browser > Device Central. • On the document window toolbar, click and hold the Preview/Debug In browser button
and select Preview
In Device Central. The file is displayed in the Device Central Emulator tab. To continue testing, double-click the name of a different device in the Device Sets or Available Deviceslists.
More Help topics “Working with Device Central and Dreamweaver” on page 359
Last updated 3/28/2012
276
Chapter 11: Working with page code General information about coding in Dreamweaver More Help topics “Code hints” on page 287 “Setting coding preferences” on page 282 “Customizing keyboard shortcuts” on page 282 “Make pages XHTML-compliant” on page 308 “Search for tags, attributes, or text in code” on page 300 “Save and recall search patterns” on page 301 “Optimizing the workspace for visual development” on page 525 “Displaying database records” on page 555
Supported languages In addition to text-editing capabilities, Adobe® Dreamweaver® CS5 provides various features, such as code hints, to help you code in the following languages:
• HTML • XHTML • CSS • JavaScript • ColdFusion Markup Language (CFML) • VBScript (for ASP) • C# and Visual Basic (for ASP.NET) • JSP • PHP Other languages, such as Perl, are not supported by the language-specific coding features in Dreamweaver; for example, you can create and edit Perl files, but code hints don’t apply to that language.
Invalid markup If your document contains invalid code, Dreamweaver displays that code in Design view and optionally highlights it in Code view. If you select the code in either view, the Property inspector displays information about why it’s invalid and how to fix it. Note: The option to highlight invalid code in Code view is turned off by default. To turn it on, switch to Code View (View > Code) and then select View > Code View Options > Highlight Invalid Code. You can also specify preferences for automatically rewriting various kinds of invalid code when you open a document.
Last updated 3/28/2012
277
USING DREAMWEAVER Working with page code
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, text), 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:
Or, if the XHTML document has a frameset:
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:
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:
Generates correctly nested code and, when cleaning up XHTML, corrects nesting in code that was not generated by Dreamweaver.
This is a bad example. This is a good example.
Last updated 3/28/2012
278
USING DREAMWEAVER Working with page code
XHTML requirement
Actions Dreamweaver performs
All element and attribute names must be lowercase.
Forces HTML element and attribute names to be lowercase in the XHTML code that it generates and when cleaning up XHTML, regardless of your tag and attribute case preferences.
Every element must have a closing tag, unless it is declared in the DTD Inserts closing tags in the code that it generates, and when cleaning as EMPTY. up XHTML. Empty elements must have a closing tag, or the opening tag must end Inserts empty elements with a space before the closing slash in empty with />. For example, is not valid; the correct form is tags in the code that it generates, and when cleaning up XHTML. or . Following are the empty elements: area, base, basefont, br, col, frame, hr, img, input, isindex, link, meta, and param. And for backwards-compatibility with browsers that are not XMLenabled, there must be a space before the /> (for example, , not ). Attributes can’t be minimized; for example, is not valid; the correct form is | .
Inserts full attribute-value pairs in the code that it generates, and when cleaning up XHTML.
This affects the following attributes: checked, compact, declare, defer, disabled, ismap, multiple, noresize, noshade, nowrap, readonly, and selected.
Note: If an HTML browser does not support HTML 4, it might fail to interpret these Boolean attributes when they appear in their full form.
All attribute values must be surrounded by quotation marks.
Places quotation marks around attribute values in the code that it generates, and when cleaning up XHTML.
The following elements must have an id attribute as well as a name Sets the name and id attributes to the same value, whenever the name attribute is set by a Property inspector, in the code that attribute: a, applet, form, frame, iframe, img, and map. For example, Introduction is not valid; the Dreamweaver generates, and when cleaning up XHTML. correct form is Introduction or Introduction.
For attributes with values of an enumerated type, the values must be Forces enumerated type values to be lowercase in the code that it lowercase. generates, and when cleaning up XHTML. An enumerated type value is a value from a specified list of allowed values; for example, the align attribute has the following allowed values: center, justify, left, and right. All script and style elements must have a type attribute. (The type attribute of the script element has been required since HTML 4, when the language attribute was deprecated.) All img and area elements must have an alt attribute.
Sets the type and language attributes in script elements, and the type attribute in style elements, in the code that it generates and when cleaning up XHTML. Sets these attributes in the code that it generates and, when cleaning up XHTML, reports missing alt attributes.
Regular expressions Regular expressions are patterns that describe character combinations in text. Use them in your code searches to help describe concepts such as lines that begin with “var” and attribute values that contain a number. The following table lists the special characters in regular expressions, their meanings, and usage examples. To search for text containing one of the special characters in the table, escape the special character by preceding it with a backslash. For example, to search for the actual asterisk in the phrase some conditions apply*, your search pattern might look like this: apply\*. If you don’t escape the asterisk, you’ll find all the occurrences of “apply” (as well as any of “appl”, “applyy”, and “applyyy”), not just the ones followed by an asterisk.
Last updated 3/28/2012
279
USING DREAMWEAVER Working with page code
Character
Matches
Example
^
Beginning of input or line.
^T matches “T” in “This good earth” but not in “Uncle Tom’s
Cabin” $
End of input or line.
h$ matches “h” in “teach” but not in “teacher”
*
The preceding character 0 or more times.
um* matches “um” in “rum”, “umm” in “yummy”, and “u” in “huge”
+
The preceding character 1 or more times.
um+ matches “um” in “rum” and “umm” in “yummy” but
nothing in “huge” ?
.
The preceding character at most once (that is, indicates that the preceding character is optional).
st?on matches “son” in “Johnson” and “ston” in “Johnston”
Any single character except newline.
.an matches “ran” and “can” in the phrase “bran muffins can
but nothing in “Appleton” or “tension”
be tasty” x|y
Either x or y.
FF0000|0000FF matches “FF0000” in bgcolor="#FF0000" and “0000FF’” in font color="#0000FF"
{n}
Exactly n occurrences of the preceding character.
o{2} matches “oo” in “loom” and the first two o’s in “mooooo” but nothing in “money”
{n,m}
At least n, and at most m, occurrences of the preceding character.
F{2,4} matches “FF” in “#FF0000” and the first four Fs in
[abc]
Any one of the characters enclosed in the brackets. Specify a range of characters with a hyphen (for example, [a-f] is equivalent to [abcdef]).
[e-g] matches “e” in “bed”, “f” in “folly”, and ”g” in “guard”
[^abc]
Any character not enclosed in the brackets. [^aeiou] initially matches “r” in “orange”, “b” in “book”, and Specify a range of characters with a hyphen (for “k” in “eek!” example, [^a-f] is equivalent to [^abcdef]).
\b
A word boundary (such as a space or carriage return).
\bb matches “b” in “book” but nothing in “goober” or “snob”
\B
Anything other than a word boundary.
\Bb matches “b” in “goober” but nothing in “book”
\d
Any digit character. Equivalent to [0-9].
\d matches “3” in “C3PO” and “2” in “apartment 2G”
\D
Any nondigit character. Equivalent to [^0-9].
\D matches “S” in “900S” and “Q” in “Q45”
\f
Form feed.
\n
Line feed.
\r
Carriage return.
\s
Any single white-space character, including space, tab, form feed, or line feed.
\sbook matches ”book” in “blue book” but nothing in “notebook”
\S
Any single non-white-space character.
\Sbook matches “book” in “notebook” but nothing in “blue
#FFFFFF
book” \t
A tab.
Last updated 3/28/2012
280
USING DREAMWEAVER Working with page code
Character
Matches
Example
\w
Any alphanumeric character, including underscore. Equivalent to [A-Za-z0-9_].
b\w* matches “barking” in “the barking dog” and both “big” and “black” in “the big black dog”
\W
Any non-alphanumeric character. Equivalent to \W matches “&” in “Jake&Mattie” and “%” in “100%” [^A-Za-z0-9_].
Control+Enter or Shift+Enter (Windows), or Control+ Return or Shift+Return or Command+ Return (Macintosh)
Return character. Make sure that you deselect the Ignore Whitespace Differences option when searching for this, if not using regular expressions. Note that this matches a particular character, not the general notion of a line break; for instance, it doesn’t match a tag or a tag. Return characters appear as spaces in Design view, not as line breaks.
Use parentheses to set off groupings within the regular expression to be referred to later. Then use $1, $2, $3, and so on in the Replace With field to refer to the first, second, third, and later parenthetical groupings. Note: In the Search For box, to refer to a parenthetical grouping earlier in the regular expression, use \1, \2, \3, and so on instead of $1, $2, $3. For example, searching for (\d+)\/(\d+)\/(\d+) and replacing it with $2/$1/$3 swaps the day and month in a date separated by slashes, thereby converting between American-style dates and European-style dates.
Server behavior code When you develop a dynamic page and select a server behavior from the Server Behaviors panel, Dreamweaver inserts one or more code blocks into your page to make the server behavior work. If you manually change the code within a code block, you can no longer use panels such as the Bindings and Server Behaviors panels to edit the server behavior. Dreamweaver looks for specific patterns in the page code to detect server behaviors and display them in the Server Behaviors panel. If you change a code block’s code in any way, Dreamweaver can no longer detect the server behavior and display it in the Server Behaviors panel. However, the server behavior still exists on the page, and you can edit it in the coding environment in Dreamweaver.
Setting up your coding environment Using coder-oriented workspaces You can adapt the coding environment in Dreamweaver to fit the way you work. For example, you can change the way you view code, set up different keyboard shortcuts, or import and use your favorite tag library. Dreamweaver comes with several workspace layouts designed for an optimal coding experience. From the workspace switcher on the Application bar, you can select from Application Developer, Application Developer Plus, Coder, and Coder Plus workspaces. All of these workspaces show Code view by default (in either the entire Document window, or in Code and Design views), and have panels docked on the left side of the screen. All but Application Developer Plus eliminate the Property inspector from the default view. If none of the pre-designed workspaces offer exactly what you need, you can customize your own workspace layout by opening and docking panels where you want them, and then saving the workspace as a custom workspace.
Last updated 3/28/2012
281
USING DREAMWEAVER Working with page code
More Help topics “Manage windows and panels” on page 21 “Save and switch workspaces” on page 25 “Customize keyboard shortcuts” on page 31 “Managing tag libraries” on page 323
Viewing code You can view the source code for the current document in several ways: you can display it in the Document window by enabling Code view, you can split the Document window to display both the page and its associated code, or you can work in the Code inspector, a separate coding window. The Code inspector works just like Code view; you can think of it as a detachable Code view for the current document.
More Help topics “Change the code format” on page 283 “Set code hints preferences” on page 289 “Set the code colors” on page 285
View code in the Document window ❖ Select View > Code.
Code and edit a page simultaneously in the Document window 1 Select View > Code and Design.
The code appears in the top pane and the page appears in the bottom pane. 2 To display the page on top, select Design View On Top from the View Options menu on the Document toolbar. 3 To adjust the size of the panes in the Document window, drag the splitter bar to the desired position. The splitter
bar is located between the two panes. Code view is updated automatically when you make changes in Design view. However, after making changes in Code view, you must manually update the document in Design view by clicking in Design view or pressing F5.
View code in a separate window with the Code inspector The Code inspector lets you work in a separate coding window, just like working in Code view. ❖ Select Window > Code Inspector. The toolbar includes the following options: File Management Puts or gets the file. Preview/Debug In Browser Previews or debugs your document in a browser. Refresh Design View Updates the document in Design view so that it reflects any changes you made in the code.
Changes you make in the code don’t automatically appear in Design view until you perform certain actions, such as saving the file or clicking this button. Reference Opens the Reference panel. See “Use language-reference material” on page 301. Code Navigation Lets you move quickly in the code. See “Go to a JavaScript or VBScript function” on page 297. View Options Lets you determine how the code is displayed. See “Set the code appearance” on page 282.
Last updated 3/28/2012
282
USING DREAMWEAVER Working with page code
To use the Coding toolbar along the left side of the window, see “Insert code with the Coding toolbar” on page 291.
Customizing keyboard shortcuts You can use your favorite keyboard shortcuts in Dreamweaver. If you’re accustomed to using specific keyboard shortcuts—for example, Shift+Enter to add a line break, or Control+G to go to a specific position in the code—you can add them to Dreamweaver using the Keyboard Shortcut Editor. For instructions, see “Customize keyboard shortcuts” on page 31.
More Help topics “Work with code snippets” on page 299
Open files in Code view by default When you open a file type that normally doesn’t contain any HTML (for example, a JavaScript file), the file opens in Code view (or Code inspector) instead of Design view. You can specify which file types open in Code view. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select File Types/Editors from the Category list on the left. 3 In the Open In Code View box, add the filename extension of the file type you want to open automatically in Code view.
Type a space between filename extensions. You can add as many extensions as you like.
More Help topics “Use an external editor” on page 286 “Set Validator preferences” on page 308
Setting coding preferences About coding preferences You can set coding preferences such as code formatting and coloring, among others, to meet your specific needs. Note: To set advanced preferences, use the Tag Library editor (see “Managing tag libraries” on page 323).
Set the code appearance You can set word wrapping, display line numbers for the code, highlight invalid code, set syntax coloring for code elements, set indenting, and show hidden characters from the View > Code View Options menu. 1 View a document in Code view or the Code inspector. 2 Do one of the following:
• Select View > Code View Options • Click the View Options button
in the toolbar at the top of Code view or the Code inspector.
Last updated 3/28/2012
283
USING DREAMWEAVER Working with page code
3 Select or deselect any of the following options: Word Wrap Wraps the code so that you can view it without scrolling horizontally. This option doesn’t insert line
breaks; it just makes the code easier to view. Line Numbers Displays line numbers along the side of the code. Hidden Characters Displays special characters in place of white space. For example, a dot replaces each space, a double chevron replaces each tab, and a paragraph marker replaces each line break.
Note: Soft line breaks that Dreamweaver uses for word wrapping are not displayed with a paragraph marker. Highlight Invalid Code Causes Dreamweaver to highlight in yellow all HTML code that isn’t valid. When you select an invalid tag, the Property inspector displays information on how to correct the error. Syntax Coloring Enables or disables code coloring. For information on changing the coloring scheme, see “Set the
code colors” on page 285. Auto Indent Makes your code indent automatically when you press Enter while writing code. The new line of code
indents to the same level as the previous line. For information on changing the indent spacing, see the Tab Size option in “Change the code format” on page 283.
More Help topics “Viewing code” on page 281 “Coding toolbar overview” on page 11 “Set code hints preferences” on page 289
Change the code format You can change the look of your code by specifying formatting preferences such as indentation, line length, and the case of tag and attribute names. All the Code Format options, except the Override Case Of option, are automatically applied only to new documents or additions to documents that you subsequently create. To reformat existing HTML documents, open the document, and select Commands > Apply Source Formatting. 1 Select Edit > Preferences. 2 Select Code Format from the Category list on the left. 3 Set any of the following options: Indent Indicates whether code generated by Dreamweaver should be indented (according to the indentation rules specified in these preferences) or not.
Note: Most of the indentation options in this dialog box apply only to code generated by Dreamweaver, not to code that you type. To make each new line of code that you type indent to the same level as the previous line, select View > Code View Options Auto-Indent option. For more information, see “Set the code appearance” on page 282. With (Text box and pop-up menu) Specifies how many spaces or tabs Dreamweaver should use to indent code that it
generates. For example, if you type 3 in the box and select Tabs in the pop-up menu, then code generated by Dreamweaver is indented using three tab characters for every level of indentation. Tab Size Determines how many characters wide each tab character appears in Code view. For example, if Tab Size is set to 4, then each tab is displayed in Code view as a four-character-wide blank space. If, additionally, Indent With is set to 3 Tabs, then code generated by Dreamweaver is indented using three tab characters for every level of indentation, which appears in Code view as a twelve-character-wide blank space.
Last updated 3/28/2012
284
USING DREAMWEAVER Working with page code
Note: Dreamweaver indents using either spaces or tabs; it doesn’t convert a run of spaces to a tab when inserting code. Line Break Type Specifies the type of remote server (Windows, Macintosh, or UNIX) that hosts your remote site.
Choosing the correct type of line break characters ensures that your HTML source code appears correctly when viewed on the remote server. This setting is also useful when you are working with an external text editor that recognizes only certain kinds of line breaks. For example, use CR LF (Windows) if Notepad is your external editor, and use CR (Macintosh) if SimpleText is your external editor. Note: For servers that you connect to using FTP, this option applies only to binary transfer mode; the ASCII transfer mode in Dreamweaver ignores this option. If you download files using ASCII mode, Dreamweaver sets line breaks based on the operating system of your computer; if you upload files using ASCII mode, the line breaks are all set to CR LF. Default Tag Case and Default Attribute Case Control the capitalization of tag and attribute names. These options are applied to tags and attributes that you insert or edit in Design view, but they are not applied to the tags and attributes that you enter directly in Code view, or to the tags and attributes already in a document when you open it (unless you also select one or both of the Override Case Of options).
Note: These preferences apply only to HTML pages. Dreamweaver ignores them for XHTML pages because uppercase tags and attributes are invalid XHTML. Override Case Of: Tags and Attributes Specifies whether to enforce your specified case options at all times, including
when you open an existing HTML document. When you select one of these options and click OK to dismiss the dialog box, all tags or attributes in the current document are immediately converted to the specified case, as are all tags or attributes in each document you open from then on (until you deselect this option again). Tags or attributes you type in Code view and in the Quick Tag Editor are also converted to the specified case, as are tags or attributes you insert using the Insert panel. For example, if you want tag names always to be converted to lowercase, specify lowercase in the Default Tag Case option, and then select the Override Case Of: Tags option. Then when you open a document that contains uppercase tag names, Dreamweaver converts them all to lowercase. Note: Older versions of HTML allowed either uppercase or lowercase tag and attribute names, but XHTML requires lowercase for tag and attribute names. The web is moving toward XHTML, so it’s generally best to use lowercase tag and attribute names. TD Tag: Do Not Include A Break Inside The TD Tag Addresses a rendering problem that occurs in some older browsers when white space or line breaks exist immediately after a | tag, or immediately before a | tag. When you select this option, Dreamweaver does not write line breaks after a or before a | tag, even if the formatting in the Tag Library indicates that the line break should be there. Advanced Formatting Lets you set formatting options for Cascading Style Sheets(CSS) code and for individual tags and attributes in the Tag Library Editor. White Space Character (Japanese version only) Lets you select either or Zenkaku space for HTML code. The white space selected in this option will be used for empty tags when creating a table and when the “Allow Multiple Consecutive Spaces” option is enabled in Japanese Encoding pages.
More Help topics “Format CSS code” on page 138 “Set code hints preferences” on page 289
Set the code rewriting preferences Use the code rewriting preferences to specify how and whether Dreamweaver modifies your code while opening documents, when copying and pasting form elements, and when entering attribute values and URLs using tools such as the Property inspector. These preferences have no effect when you edit HTML or scripts in Code view.
Last updated 3/28/2012
285
USING DREAMWEAVER Working with page code
If you disable the rewriting options, invalid-markup items are displayed in the Document window for HTML that it would have rewritten. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Code Rewriting from the Category list on the left. 3 Set any of the following options: Fix Invalidly Nested and Unclosed Tags Rewrites overlapping tags. For example, text is rewritten as text. This option also inserts closing quotation marks and closing brackets if they are missing.
Rename Form Items When Pasting Ensures you don’t have duplicate names for form objects. This option is enabled by
default. Note: Unlike the other options in this preferences dialog box, this option does not apply when you open a document, only when you copy and paste a form element. Remove Extra Closing Tags Deletes closing tags that have no corresponding opening tag. Warn When Fixing Or Removing Tags Displays a summary of technically invalid HTML that Dreamweaver attempted to correct. The summary notes the location of the problem (using line and column numbers) so that you can find the correction and ensure that it’s rendering as intended. Never Rewrite Code: In Files With Extensions Allows you to prevent Dreamweaver from rewriting code in files with
the specified filename extensions. This option is particularly useful for files that contain third-party tags. Encode , &, And " In Attribute Values Using & Ensures that attribute values that you enter or edit using Dreamweaver tools such as the Property inspector contain only legal characters. This option is enabled by default.
Note: This option and the following options do not apply to URLs that you type in Code view. Also, they do not cause existing code already in a file to change. Do Not Encode Special Characters Prevents Dreamweaver from changing URLs to use only legal characters. This
option is enabled by default. Encode Special Characters In URL Using Ensures that when you enter or edit URLs using Dreamweaver tools such as the Property inspector, those URLs contain only legal characters. Encode Special Characters In URL Using % Operates the same way as the preceding option, but uses a different method of encoding special characters. This encoding method (using the percent sign) may be more compatible with older browsers, but doesn’t work as well with characters from some languages.
More Help topics “Clean up Microsoft Word HTML files” on page 69 “Set code hints preferences” on page 289
Set the code colors Use the code coloring preferences to specify colors for general categories of tags and code elements, such as formrelated tags or JavaScript identifiers. To set color preferences for a specific tag, edit the tag definition in the Tag Library editor. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Code Coloring from the Category list on the left. 3 Select a document type from the Document type list. Any edits you make to code coloring preferences will affect all
documents of this type.
Last updated 3/28/2012
286
USING DREAMWEAVER Working with page code
4 Click the Edit Coloring Scheme button. 5 In the Edit Coloring Scheme dialog box, select a code element from the Styles For list, and set its text color,
background color, and (optional) style (bold, italic, or underline). The sample code in the Preview pane changes to match the new colors and styles. Click OK to save your changes and close the Edit Coloring Scheme dialog box. 6 Make any other necessary selections in Code Coloring preferences and click OK. Default background sets the default background color for Code view and the Code inspector. Hidden characters sets the color for hidden characters. Live Code background sets the background color for Live Code view. The default color is yellow. Live Code changes sets the highlighting color of code that changes in Live Code view. The default color is pink. Read only background sets the background color for read only text.
More Help topics “Customize code coloring preferences for a template” on page 397 “Edit libraries, tags, and attributes” on page 324 “Preview Live Code” on page 273 “Set code hints preferences” on page 289
Use an external editor You can specify an external editor to use for editing files with specific filename extensions. For example, you can start a text editor such as BBEdit, Notepad, or TextEdit from Dreamweaver to edit JavaScript (JS) files. You can assign different external editors for different filename extensions.
More Help topics “Open files in Code view by default” on page 282
Set an external editor for a file type 1 Select Edit > Preferences. 2 Select File Types/Editors from the Category list on the left, set the options, and click OK. Open In Code View Specifies the filename extensions that automatically open in Code view in Dreamweaver. External Code Editor Specifies the text editor to use. Reload Modified Files Specifies the behavior when Dreamweaver detects that changes were made externally to a
document that is open in Dreamweaver. Save On Launch Specifies whether Dreamweaver should always save the current document before starting the editor,
never save the document, or prompt you to ask whether to save or not each time you start the external editor. Fireworks Specifies editors for various media file types.
Start an external code editor ❖ Select Edit > Edit with External Editor.
Last updated 3/28/2012
287
USING DREAMWEAVER Working with page code
Writing and editing code Code hints The code hints feature helps you insert and edit code quickly and without mistakes. As you type characters in Code view, you see a list of candidates that automatically complete your entry. For example, when you type the first characters of a tag, attribute, or CSS property name, you see a list of options beginning with those characters. This feature simplifies the insertion and editing of code. You can also use it to see the available attributes for a tag, the available parameters for a function, or the available methods for an object. Code hints are available for several kinds of code. When you type the beginning character of a particular code type, you see a list of appropriate candidates. For example, to display a list of code hints for HTML tag names, type a right angle bracket ( Code), place the insertion point inside a tag. 2 Press Control+Spacebar.
Insert code in Code view by using code hints 1 Type the beginning of a piece of code. For example, to insert a tag, type a right angle bracket ( Preferences > Code Hints, and then select one of the Close Tags options.
Edit a tag by using code hints • To replace an attribute with a different attribute, delete the attribute and its value. Then add an attribute and its value as described in the previous procedure.
• To change a value, delete the value, and then add a value as described in the previous procedure.
Refreshing JavaScript code hints Dreamweaver automatically refreshes the list of available code hints as you work in JavaScript files. For example, suppose you are working in a primary HTML file and switch to a JavaScript file to make a change. That change is reflected in the list of code hints when you return to the primary HTML file. However, automatic updating works only if you edit your JavaScript files in Dreamweaver. If you edit your JavaScript files outside Dreamweaver, press Control+period to refresh the JavaScript code hints.
Code hinting and syntax errors Code hints sometimes don’t work properly if Dreamweaver detects syntax errors in your code. Dreamweaver alerts you to syntax errors by displaying information about them in a bar at the top of the page. The Syntax Error Information Bar displays the first line of code on which Dreamweaver encounters the error. As you fix errors, Dreamweaver continues to display any errors that occur later. Dreamweaver provides additional help by highlighting (in red) the line numbers where syntax errors occur. The highlight appears in the Code view of the file that contains the error.
Last updated 3/28/2012
289
USING DREAMWEAVER Working with page code
Dreamweaver displays syntax errors not only for the current page but also for related pages. For example, suppose you are working on an HTML page that uses an included JavaScript file. If the included file contains an error, Dreamweaver displays an alert for the JavaScript file as well. You can easily open the related file containing the error by clicking its name at the top of the document. You can disable the Syntax Error Information Bar by clicking the Syntax Error Alerts button in the Coding toolbar.
Set code hints preferences You can change default preferences for code hints. For example, if you don’t want to show CSS property names or Spry code hints, you can deselect them in code hints preferences. You can also set preferences for code hint delay time and closing tags. Even if code hints are disabled, you can still display a pop-up hint in Code view by pressing Control+Spacebar. 1 Select Edit > Preferences. 2 Select Code Hints from the Category list on the left. 3 Set any of the following options: Close Tags Specifies how you want Dreamweaver to insert closing tags. By default, Dreamweaver inserts the closing
tag automatically after you type the characters ) of the opening tag, or so that no closing tag is inserted at all. Enable Code Hints Displays code hints while you enter code in Code view. Drag the Delay slider to set the time in seconds before appropriate hints are displayed. Enable Description Tooltips Displays an extended description (if available) of the selected code hint. Menus Sets exactly which type of code hints you want displayed while typing. You can use all or some of the menus.
More Help topics “Use the hints menu in the Quick Tag Editor” on page 313 W3C Document Object Model Code hinting tutorial
Site-specific code hints Dreamweaver CS5 lets developers working with Joomla, Drupal, Wordpress or other frameworks, to view PHP code hints as they write in Code view. To display these code hints, you first need to create a configuration file using the SiteSpecific Code Hints dialog box. The configuration tells Dreamweaver where to look for code hints that are specific to your site. For a video tutorial on working with Site-specific code hints, see www.adobe.com/go/learn_dw_comm13_en.
Create the configuration file Use the Site-Specific Code Hints dialog box to create the configuration file needed to display code hints in Dreamweaver. By default, Dreamweaver stores the configuration file in the Adobe Dreamweaver CS5\configuration\Shared\Dinamico\Presets directory.
Last updated 3/28/2012
290
USING DREAMWEAVER Working with page code
Note: The code hints you create are specifically for the site selected in the Dreamweaver Files panel. In order for the code hints to display, the page you are working on must reside in the currently selected site. 1 Select Site > Site-Specific Code Hints.
By default, the Site-Specific Code Hints feature scans your site to determine which Content Management System (CMS) framework you’re using. Dreamweaver supports three frameworks by default: Drupal, Joomla, and Wordpress. The four buttons to the right of the Structure pop-up menu let you import, save, rename, or delete framework structures. Note: You cannot delete or rename the existing default framework structures. 2 In the sub-root text box, specify the sub-root folder where you store your framework’s files. You can click the folder
icon next to the text box to browse to the framework files’ location. Dreamweaver displays a file tree structure of folders that contain your framework files. If the folders and/or files you want to scan are all displayed, click OK to run the scan. If you want to customize the scan, go on to the next steps. 3 Click the plus (+) button above the Files window to select a file or folder that you want to add to the scan. In the
Add Files/Folders dialog box, you can specify particular file extensions that you want to include. Note: Specifying particular file extensions speeds up the scanning process. 4 To remove files from the scan, select the files you don’t want scanned, and then click the minus (-) button above
the Files window. Note: If Drupal or Joomla is the selected framework, the Site-Specific Code Hints dialog box displays an additional path to a file within your Dreamweaver configuration folder. Don’t delete this—it’s required when using these frameworks. 5 To customize how the Site-Specific Code Hints feature treats a particular file or folder, select it from the list and do
one of the following:
• Select Scan This Folder to include the selected folder in the scan. • Select Recursive to include all files and folders within a selected directory. • Click the Extensions button to open the Find Extensions dialog box, where you can specify the file extensions you want included in your scan for a particular file or folder.
Save site structure You can save the customized site structure you’ve created in the Site-Specific Code Hints dialog box. 1 Create the structure of files and folders as you want it, adding and deleting files and folders as necessary. 2 Click the Save Structure button in the upper right-hand corner of the dialog box. 3 Specify a name for your site structure and click Save.
Note: If the name you specify is already in use, Dreamweaver prompts you to enter a different name, or to confirm that you want to overwrite the structure with the same name. You cannot overwrite any of the default framework structures.
Rename site structures When renaming your site structure, keep in mind that you cannot use the names of any of the three default site framework structures, or the word “custom”. 1 Display the structure that you want to rename.
Last updated 3/28/2012
291
USING DREAMWEAVER Working with page code
2 Click the Rename Structure icon button in the upper right-hand corner of the dialog box. 3 Specify a new name for the structure and click Rename.
Note: If the name you specify is already in use, Dreamweaver prompts you to enter a different name, or to confirm that you want to overwrite the structure with the same name. You cannot overwrite any of the default framework structures.
Add files or folders to a site structure You can add any files or folders that are associated with your framework. After that, you can specify the file extensions of the files you want to scan. (See the next section.) 1 Click the plus (+) button above the Files window to open the Add File/Folder dialog box. 2 In the Add File/Folder text box, enter the path to the file or folder you want to add. You can also click the folder
icon next to the text box to browse to a file or folder. 3 Click the plus (+) button above the Extensions window to specify the file extensions of files you want to scan.
Note: Specifying particular file extensions speeds up the scanning process. 4 Click Add.
Scan a site for file extensions Use the Find Extensions dialog box to view and edit file extensions that are included in the site structure. 1 In the Site-Specific Code Hints dialog box, click the Extensions button.
The Find Extensions dialog box lists the current scannable extensions. 2 To add another extension to the list, click the plus (+) button above the Extensions window. 3 To delete an extension from the list, click the minus (-) button.
Insert code with the Coding toolbar 1 Make sure you are in Code view (View > Code). 2 Position the insertion point in the code, or select a block of code. 3 Click a button in the Coding toolbar, or select an item from a pop-up menu in the toolbar.
To find out what each button does, position the pointer over it until a tooltip appears. The Coding toolbar displays the following buttons by default: Open Documents Lists the documents that are open. When you select one, it is displayed in the Document window. Show Code Navigator Displays the Code Navigator. For more information, see “Navigate to related code” on
page 296. Collapse Full Tag Collapses the content between a set of opening and closing tags (for example, the content between ). You must place the insertion point in the opening or closing tag and then click the Collapse Full Tag button to collapse the tag.
You can also collapse the code outside a full tag by placing the insertion point in an opening or closing tag and Alt-clicking (Windows) or Option-clicking (Macintosh) the Collapse Full Tag button. Additionally, Control-clicking this button disables “smart collapse” so that Dreamweaver doesn’t adjust the content it collapses outside full tags. For more information, see “About collapsing code” on page 303. Collapse Selection Collapses the selected code.
Last updated 3/28/2012
292
USING DREAMWEAVER Working with page code
You can also collapse the code outside a selection by Alt-clicking (Windows) or Option-clicking (Macintosh) the Collapse Selection button. Additionally, Control-clicking this button disables “smart collapse” so that you can collapse exactly what you selected without any manipulation from Dreamweaver. For more information, see “About collapsing code” on page 303. Expand All Restores all collapsed code. Select Parent Tag Selects the content and surrounding opening and closing tags of the line in which you’ve placed the
insertion point. If you repeatedly click this button, and your tags are balanced, Dreamweaver eventually selects the outermost html and /html tags. Balance Braces Selects the content and surrounding parentheses, braces, or square brackets of the line in which you placed the insertion point. If you repeatedly click this button, and your surrounding symbols are balanced, Dreamweaver eventually selects the outermost braces, parentheses, or brackets in the document. Line Numbers Lets you hide or show numbers at the beginning of each line of code. Highlight Invalid Code Highlights invalid code in yellow. Syntax Error Alerts in Info Bar Enables or disables an information bar at the top of the page that alerts you to syntax
errors. When Dreamweaver detects a syntax error, the Syntax Error Information Bar specifies the line in the code where the error occurs. Additionally, Dreamweaver highlights the error’s line number on the left side of the document in Code view. The info bar is enabled by default, but only appears when Dreamweaver detects syntax errors in the page. Apply Comment Lets you wrap comment tags around selected code, or open new comment tags.
• Apply HTML Comment wraps the selected code with , or opens a new tag if no code is selected. • Apply // Comment inserts // at the beginning of each line of selected CSS or JavaScript code, or inserts a single // tag if no code is selected.
• Apply /* */ wraps the selected CSS or JavaScript code with /* and */. • Apply ' Comment is for Visual Basic code. It inserts a single quotation mark at the beginning of each line of a Visual Basic script, or inserts a single quotation mark at the insertion point if no code is selected.
• When you are working in a ASP, ASP.NET, JSP, PHP, or ColdFusion file and you select the Apply Server Comment option, Dreamweaver automatically detects the correct comment tag and applies it to your selection. Remove Comment Removes comment tags from the selected code. If a selection includes nested comments, only the outer comment tags are removed. Wrap Tag Wraps selected code with the selected tag from the Quick Tag Editor. Recent Snippets Lets you insert a recently used code snippet from the Snippets panel. For more information, see
“Work with code snippets” on page 299. Move or Convert CSS Lets you move CSS to another location, or convert inline CSS to CSS rules. For more
information, see “Move/export CSS rules” on page 135 and “Convert inline CSS to a CSS rule” on page 136. Indent Code Shifts the selection to the right. Outdent Code Shifts the selection to the left. Format Source Code Applies previously specified code formats to selected code, or to the entire page if no code is
selected. You can also quickly set code formatting preferences by selecting Code Formatting Settings from the Format Source Code button, or edit tag libraries by selecting Edit Tag Libraries. The number of buttons available in the Coding toolbar varies depending on the size of the Code view in the Document window. To see all of the available buttons, resize the Code view window or click the expander arrow at the bottom of the Coding toolbar.
Last updated 3/28/2012
293
USING DREAMWEAVER Working with page code
You can also edit the Coding toolbar to display more buttons (such as Word Wrap, Hidden Characters, and Auto Indent) or hide buttons that you don’t want to use. To do this, however, you must edit the XML file that generates the toolbar. For more information, see Extending Dreamweaver. Note: The option to view hidden characters, which is not a default button in the Coding toolbar, is available from the View menu (View > Code View Options > Hidden Characters).
More Help topics “Verify tags and braces are balanced” on page 306 “Coding toolbar overview” on page 11 “Display toolbars” on page 20
Insert code with the Insert panel 1 Position the insertion point in the code. 2 Select an appropriate category in the Insert panel. 3 Click a button in the Insert panel or select an item from a pop-up menu in the Insert panel.
When you click an icon, the code may appear in your page immediately, or a dialog box may appear requesting more information to complete the code. To find out what each button does, position the pointer over it until a tooltip appears. The number and type of buttons available in the Insert panel varies depending on the current document type. It also depends on whether you’re using Code view or Design view. Although the Insert panel provides a collection of frequently used tags, it is not comprehensive. To choose from a more comprehensive selection of tags, use the Tag Chooser.
More Help topics “Use the Insert panel” on page 195
Insert tags with the Tag Chooser Use the Tag Chooser to insert in your page any tag in the Dreamweaver tag libraries (which include ColdFusion and ASP.NET tag libraries). 1 Position the insertion point in the code, right-click (Windows) or Control-click (Macintosh), and select Insert Tag.
The Tag Chooser appears. The left pane contains a list of supported tag libraries, and the right pane shows the individual tags in the selected tag library folder. 2 Select a category of tags from the tag library, or expand the category and select a subcategory. 3 Select a tag from the right pane. 4 To view syntax and usage information for the tag in the Tag Chooser, click the Tag Info button. If available,
information about the tag appears. 5 To view the same information about the tag in the Reference panel, click the icon. If available, information
about the tag appears. 6 To insert the selected tag into your code, click Insert.
Last updated 3/28/2012
294
USING DREAMWEAVER Working with page code
If the tag appears in the right pane with angle brackets (for example, ), it doesn’t require additional information, and it’s immediately inserted into the document at the insertion point. If the tag does require additional information, a tag editor appears. 7 If a tag editor opens, enter the additional information, and click OK. 8 Click the Close button.
More Help topics “About Dreamweaver tag libraries” on page 323
Insert HTML comments A comment is descriptive text that you insert in HTML code to explain the code or provide other information. The text of the comment appears only in Code view and is not displayed in a browser.
Insert a comment at the insertion point ❖ Select Insert > Comment.
In Code view, a comment tag is inserted and the insertion point is placed in the middle of the tag. Type your comment. In Design view, the Comment dialog box appears. Enter the comment and click OK.
Display comment markers in Design view ❖ Select View > Visual Aids > Invisible Elements.
Make sure that the Comments option is selected in the Invisible Elements preferences or the comment marker does not appear.
Edit an existing comment • In Code view, find the comment and edit its text. • In Design view, select the Comment marker, edit the comment’s text in the Property inspector, and then click in the Document window.
Copy and paste code 1 Copy the code from Code view or from another application. 2 Place the insertion point in Code view, and select Edit > Paste.
More Help topics “Paste and move collapsed code fragments” on page 304
Edit tags with Tag editors Use Tag editors to view, specify, and edit the attributes of tags. 1 Right-click (Windows) or Control-click (Macintosh) a tag in Code view or an object in Design view, and select Edit
Tag from the pop-up menu. (The contents of this dialog box change depending on the selected tag.) 2 Specify or edit attributes for the tag and click OK.
Last updated 3/28/2012
295
USING DREAMWEAVER Working with page code
To get more information about the tag within the Tag editor, click Tag Info.
Edit code with the Coding context menu 1 In Code view, select some code and right-click (Windows) or Control-click (Macintosh). 2 Select the Selection submenu, and select any of the following options: Collapse Selection Collapses the selected code. Collapse Outside Selection Collapses all of the code outside the selected code. Expand Selection Expands the selected code fragment. Collapse Full Tag Collapses the content between a set of opening and closing tags (for example, the content between ).
Collapse Outside Full Tag Collapses the content outside a set of opening and closing tags (for example, the content
outside ). Expand All Restores all collapsed code. Apply HTML Comment Wraps the selected code with , or opens a new tag if no code is selected. Apply /* */ Comment Wraps the selected CSS or JavaScript code with /* and */. Apply // Comment Inserts // at the beginning of each line of selected CSS or JavaScript code, or inserts a single // tag if no code is selected. Apply ' Comment Inserts a single quotation mark at the beginning of each line of a Visual Basic script, or inserts a single quotation mark at the insertion point if no code is selected. Apply Server Comment Wraps the selected code. When you are working in a ASP, ASP.NET, JSP, PHP, or ColdFusion
file and you select the Apply Server Comment option, Dreamweaver automatically detects the correct comment tag and applies it to your selection. Apply Backslash-comment Hack Wraps the selected CSS code with comment tags that will cause Internet Explorer 5 for Macintosh to ignore the code. Apply Caio Hack Wraps the selected CSS code with comment tags that will cause Netscape Navigator 4 to ignore the code. Remove Comment Removes comment tags from the selected code. If a selection includes nested comments, only the outer comment tags are removed. Remove Backslash-comment Hack Removes comment tags from the selected CSS code. If a selection includes nested comments, only the outer comment tags are removed. Remove Caio Hack Removes comment tags from the selected CSS code. If a selection includes nested comments, only the outer comment tags are removed Convert Tabs to Spaces Converts each tab in the selection to a number of spaces equal to the Tab Size value set in Code
Format preferences. For more information, see “Change the code format” on page 283. Convert Spaces To Tabs Converts runs of spaces in the selection to tabs. Each run of spaces that has a number of spaces equal to the tab size is converted to one tab. Indent Indents the selection, shifting it to the right. For more information, see “Indent code blocks” on page 296. Outdent Shifts the selection to the left. Remove All Tags Removes all the tags in the selection.
Last updated 3/28/2012
296
USING DREAMWEAVER Working with page code
Convert Lines To Table Wraps the selection in a table tag with no attributes. Add Line Breaks Adds a br tag at the end of each line of the selection. Convert To Uppercase Converts all letters in the selection (including tag and attribute names and values) to uppercase. Convert To Lowercase Converts all letters in the selection (including tag and attribute names and values) to lowercase. Convert Tags To Uppercase Converts all tag and attribute names and attribute values in the selection to uppercase. Convert Tags To Lowercase Converts all tag and attribute names and attribute values in the selection to lowercase.
More Help topics “Collapse and expand code fragments” on page 303
Edit a server-language tag with the Property inspector Edit the code in a server-language tag (such as an ASP tag) without entering Code view by using the code Property inspector. 1 In Design view, select the server-language tag visual icon. 2 In the Property inspector, click the Edit button. 3 Make changes to the tag code, and click OK.
More Help topics “Set up your computer for application development” on page 504
Indent code blocks As you write and edit code in Code view or the Code inspector, you can change the indentation level of a selected block or line of code, shifting it right or left by one tab.
Indent the selected block of code • Press Tab. • Select Edit > Indent Code.
Unindent the selected block of code • Press Shift+Tab. • Select Edit > Outdent Code.
Navigate to related code The Code Navigator displays a list of code sources related to a particular selection on your page. Use it to navigate to related code sources, such as internal and external CSS rules, server-side includes, external JavaScript files, parent template files, library files, and iframe source files. When you click a link in the Code Navigator, Dreamweaver opens the file containing the relevant piece of code. The file appears in the related files area, if it is enabled. If you don’t have related files enabled, Dreamweaver opens the selected file as a separate document in the Document window. If you click a CSS rule in the Code Navigator, Dreamweaver takes you directly to that rule. If the rule is internal to the file, Dreamweaver displays the rule in Split view. If the rule is in an external CSS file, Dreamweaver opens the file and displays the rule in the related files area above the main document.
Last updated 3/28/2012
297
USING DREAMWEAVER Working with page code
You can access the Code Navigator from Design, Code, and Split views, as well as from the Code inspector. For a video overview from the Dreamweaver engineering team about working with the Code Navigator, see www.adobe.com/go/dw10codenav. For a video tutorial on working with Live View, related files, and the Code Navigator, see www.adobe.com/go/lrvid4044_dw.
Open the Code Navigator ❖ Alt+click (Windows) or Command+Option+Click (Macintosh) anywhere on the page. The Code Navigator
displays links to the code affecting the area you clicked. Click outside the Code Navigator to close it. Note: You can also open the Code Navigator by clicking the Code Navigator indicator the insertion point on your page when the mouse has been idle for 2 seconds.
. This indicator appears near
Navigate to code with the Code Navigator 1 Open the Code Navigator from the area of the page that you’re interested in. 2 Click the piece of code you want to go to.
The Code Navigator groups related code sources by file and lists the files alphabetically. For example, suppose that CSS rules in three external files affect the selection in your document. In this case, the Code Navigator lists those three files as well as the CSS rules relevant to the selection. For CSS related to a given selection, the Code Navigator functions like the CSS Styles panel in Current Mode. When you hover over links to CSS rules, the Code Navigator displays tool tips of the properties in the rule. These tool tips are useful when you want to distinguish between many rules that share the same name.
Disable the Code Navigator indicator 1 Open the Code Navigator. 2 Select Disable Indicator in the lower-right corner. 3 Click outside the Code Navigator to close it.
To re-enable the Code Navigator indicator, Alt+Click (Windows) or Command+Option+Click (Macintosh) to open the Code Navigator and deselect the Disable Indicator option.
More Help topics “Open Related Files” on page 66 Code Navigator tutorial
Go to a JavaScript or VBScript function In Code view and the Code inspector, you can view a list of all of the JavaScript or VBScript functions in your code and jump to any one of them. 1 View the document in Code view (View > Code) or the Code inspector (Window > Code Inspector). 2 Do one of the following:
• In Code view, right-click (Windows) or Control-click (Macintosh) anywhere in Code view, and select the Functions submenu from the context menu.
Last updated 3/28/2012
298
USING DREAMWEAVER Working with page code
The Functions submenu does not appear in Design view. Any JavaScript or VBScript functions in your code appear in the submenu. To see the functions listed in alphabetical order, Control-right-click (Windows) or Option-Control-click (Macintosh) in Code view, and then select the Functions submenu.
• In the Code inspector, click the Code Navigation button ({ }) on the toolbar. 3 Select a function name to jump to the function in your code.
Extract JavaScript The JavaScript Extractor (JSE) removes all or most of the JavaScript from your Dreamweaver document, exports it to an external file, and links the external file to your document. The JSE can also remove event handlers such as onclick and onmouseover from your code and then unobtrusively attach the JavaScript associated with those handlers to your document. You should be aware of the following limitations of the JavaScript Extractor before using it:
• The JSE does not extract script tags in the body of the document (except in the case of Spry widgets). There is a chance that externalizing these scripts could cause unexpected results. By default, Dreamweaver lists these scripts in the Externalize JavaScript dialog box, but does not select them for extraction. (You can manually select them if you want.)
• The JSE does not extract JavaScript from editable regions of .dwt (Dreamweaver template) files, non-editable regions of template instances, or Dreamweaver Library items.
• After you extract JavaScript using the Externalize JavaScript and Attach Unobtrusively option, you can no longer edit Dreamweaver behaviors in the Behaviors panel. Dreamweaver cannot inspect and populate the Behaviors panel with behaviors that it has attached unobtrusively.
• You cannot undo your changes once you close the page. You can, however, undo changes as long as you remain in the same editing session. Select Edit > Undo Externalize JavaScript to undo.
• Some very complex pages might not work as expected. Use care when extracting JavaScript from pages with document.write() in the body and global variables.
For a video overview from the Dreamweaver engineering team about JavaScript support in Dreamweaver, see www.adobe.com/go/dw10javascript. To use the JavaScript Extractor: 1 Open a page that contains JavaScript (for example, a Spry page). 2 Select Commands > Externalize JavaScript. 3 In the Externalize JavaScript dialog box, edit the default selections if necessary.
• Select Only Externalize JavaScript if you want Dreamweaver to move any JavaScript to an external file, and to reference that file in the current document. This option leaves event handlers such as onclick and onload in the document, and leaves Behaviors visible in the Behaviors panel.
• Select Externalize JavaScript and Attach Unobtrusively if you want Dreamweaver to 1) move JavaScript to an external file and reference it in the current document, and 2) remove event handlers from the HTML and insert them at runtime using JavaScript. When you select this option, you can no longer edit Behaviors in the Behaviors panel.
Last updated 3/28/2012
299
USING DREAMWEAVER Working with page code
• In the Edit column, deselect any edits you do not want to make, or select edits that Dreamweaver did not select by default. By default, Dreamweaver lists but does not select the following edits:
• Script blocks in the head of the document that contain document.write() or document.writeln() calls. • Script blocks in the head of the document that contain function signatures related to EOLAS handling code, which is known to use document.write().
• Script blocks in the body of the document, unless the blocks contain only Spry widget or Spry data set constructors.
• Dreamweaver automatically assigns IDs to elements that don’t already have IDs. If you don’t like these IDs, you can change them by editing the ID text boxes. 4 Click OK.
The summary dialog provides a summary of extractions. Review the extractions and click OK. 5 Save the page.
Dreamweaver creates a SpryDOMUtils.js file, as well as another file that contains the extracted JavaScript. Dreamweaver saves the SpryDOMUtils.js file in a SpryAssets folder in your site, and saves the other file at the same level as the page from which you extracted the JavaScript. Don’t forget to upload both of these dependent files to your web server when you upload the original page.
More Help topics “Building Spry pages visually” on page 399
Work with code snippets Code snippets let you store content for quick reuse. You can create, insert, edit, or delete snippets of HTML, JavaScript, CFML, ASP, PHP, and more. You can also manage and share your code snippets with team members. Some predefined snippets that you can use as a starting point are available. Snippets that contain tags and other deprecated elements and attributes are in the Legacy folder in the Snippets panel.
Insert a code snippet 1 Place the insertion point where you want to insert the code snippet, or select code to wrap a snippet around. 2 In the Snippets panel (Window > Snippets), double-click the snippet.
You can also right-click (Windows) or Control-click (Macintosh) the snippet, and then select Insert from the pop-up menu.
Create a code snippet 1 In the Snippets panel, click the New Snippet icon at the bottom of the panel. 2 Enter a name for the snippet.
Note: Snippet names can’t contain characters that are invalid in filenames, such as slashes(/ or \), special characters, or double quotes (“). 3 (Optional) Enter a text description of the snippet. This makes it easier for other team members to use the snippet.
Last updated 3/28/2012
300
USING DREAMWEAVER Working with page code
4 For Snippet Type, select Wrap Selection or Insert Block. a If you chose Wrap Selection, add code for the following options: Insert Before Type or paste the code to insert before the current selection. Insert After Type or paste the code to insert after the current selection.
To set default spacing for the blocks, use line breaks; press Enter (Windows) or Return (Macintosh) inside the text boxes. Note: Because snippets can be created as start and end blocks, you can use them to surround other tags and content. This is useful for inserting special formatting, links, navigation elements, and script blocks. Simply highlight the content you want to surround, then insert the snippet. b If you chose Insert Block, type or paste the code to insert. 5 (Optional) Select a Preview Type: Code or Design. Design Renders the code and displays it in the Preview pane of the Snippets panel. Code Displays the code in the Preview pane.
6 Click OK.
Edit or delete a code snippet ❖ In the Snippets panel, select a snippet, and click the Edit Snippet button or the Remove button at the bottom of the
panel.
Create code snippet folders and manage code snippets 1 In the Snippets panel, click the New Snippet Folder button at the bottom of the panel. 2 Drag snippets to the new folder or other folders, as desired.
Add or edit a keyboard shortcut for a snippet 1 In the Snippets panel, right-click (Windows) or Control-click (Macintosh) and select Edit Keyboard Shortcuts.
The Keyboard Shortcuts Editor appears. 2 In the Commands pop-up menu, select Snippets.
A list of snippets appears. 3 Select a snippet and assign a keyboard shortcut to it.
For more information, see “Customize keyboard shortcuts” on page 31.
Share a snippet with other members of your team 1 Find the file corresponding to the snippet that you want to share in the Configuration/Snippets folder in the
Dreamweaver application folder. 2 Copy the snippet file to a shared folder on your computer or a network computer. 3 Have the other members of the team copy the snippet file to their Configuration/Snippets folder.
Search for tags, attributes, or text in code You can search for specific tags, attributes, and attribute values. For example, you can search for all img tags that have no alt attribute.
Last updated 3/28/2012
301
USING DREAMWEAVER Working with page code
You can also search for specific text strings that are within or not within a set of container tags. For example, you can search for the word Untitled contained in a title tag to find all the untitled pages on your site. 1 Open the document to search in, or select documents or a folder in the Files panel. 2 Select Edit > Find And Replace. 3 Specify which files to search in, and then specify the kind of search to perform, and text or tags to search for.
Optionally, specify replacement text as well. Then click one of the Find buttons or one of the Replace buttons. 4 Click the Close button. 5 To search again without displaying the Find And Replace dialog box, press F3 (Windows) or Command+G
(Macintosh).
More Help topics “Regular expressions” on page 278 “Search for and replace text” on page 210
Save and recall search patterns You can save search patterns and reuse them later.
More Help topics “Regular expressions” on page 278 “Search for and replace text” on page 210
Save a search pattern 1 In the Find And Replace dialog box (Edit > Find And Replace), set the parameters for the search. 2 Click the Save Query button (the disk icon). 3 In the dialog box that appears, navigate to the folder where you want to save queries. Then type a filename that
identifies the query, and click Save. For example, if the search pattern involves looking for img tags with no alt attribute, you might name the query img_no_alt.dwr. Note: Saved queries have the filename extension .dwr. Some saved queries from older versions of Dreamweaver may have the extension .dwq.
Recall a search pattern 1 Select Edit > Find And Replace. 2 Click the Load Query button (the folder icon). 3 Navigate to the folder where your queries are saved. Then select a query file and click Open. 4 Click Find Next, Find All, Replace, or Replace All to initiate the search.
Use language-reference material The Reference panel provides you with a quick reference tool for markup languages, programming languages, and CSS styles. It provides information on the specific tags, objects, and styles that you are working with in Code view (or the Code inspector). The Reference panel also provides example code that you can paste into your documents.
Last updated 3/28/2012
302
USING DREAMWEAVER Working with page code
Open the Reference panel 1 Do one of the following in Code view:
• Right-click (Windows) or Control-click (Macintosh) a tag, attribute, or keyword, and then select Reference from the context menu.
• Place the insertion point in a tag, attribute, or keyword, and then press Shift+F1. The Reference panel opens and displays information about the tag, attribute, or keyword you clicked.
2 To adjust the text size in the Reference panel, select Large Font, Medium Font, or Small Font from the options menu
(the small arrow at the upper right of the panel).
Paste example code into your document 1 Click anywhere in example code in the reference content.
The entire code example is highlighted. 2 Select Edit > Copy, and then paste the example code into your document in Code view.
Browse the reference content in the Reference panel 1 To display tags, objects, or styles from another book, select a different book from the Book pop-up menu. 2 To view information about a specific item, select it from the Tag, Object, Style, or CFML pop-up menu (depending
on which book you selected). 3 To view information about an attribute of the selected item, select the attribute from the pop-up menu next to the
Tag, Object, Style, or CFML pop-up menu. This menu contains the list of attributes for the item you select. The default selection is Description, which displays a description of the chosen item.
Print code You can print your code to edit it offline, archive it, or distribute it. 1 Open a page in Code view. 2 Select File > Print Code. 3 Specify printing options, and then click OK (Windows) or Print (Macintosh).
Last updated 3/28/2012
303
USING DREAMWEAVER Working with page code
Collapsing code About collapsing code You can collapse and expand code fragments so that you can view different sections of your document without having to use the scroll bar. For example, to see all of the CSS rules in the head tag that apply to a div tag farther down the page, you can collapse everything between the head tag and the div tag so that you can see both sections of code at once. Although you can select code fragments by making selections in Design view or Code view, you can collapse code only in Code view. Note: Files created from Dreamweaver templates display all code as fully expanded, even if the template file (.dwt) contains collapsed code fragments.
More Help topics “Paste and move collapsed code fragments” on page 304 “Insert code with the Coding toolbar” on page 291 “Clean up code” on page 305
Collapse and expand code fragments When you select code, a set of collapse buttons is displayed next to the selection (Minus symbols in Windows; vertical triangles on the Macintosh). Click the buttons to collapse and expand the selection. When the code is collapsed, the collapse buttons change to an expand button (a Plus button in Windows; a horizontal triangle on the Macintosh). Sometimes, the exact fragment of code that you selected is not collapsed. Dreamweaver uses “smart collapse” to collapse the most common and visually pleasing selection. For example, if you selected an indented tag and then selected the indented spaces before the tag as well, Dreamweaver would not collapse the indented spaces, because most users would expect their indentations to be preserved. To disable smart collapse and force Dreamweaver to collapse exactly what you selected, hold down the Control key before collapsing your code. Also, a warning icon on collapsed code fragments is displayed if a fragment contains errors or code that is unsupported by certain browsers. You can also collapse the code by Alt-clicking (Windows) or Option-clicking (Macintosh) one of the collapse buttons, or by clicking the Collapse Selection button in the Coding toolbar. 1 Select some code. 2 Select Edit > Code Collapse, and select any of options.
More Help topics “Edit code with the Coding context menu” on page 295 “Insert code with the Coding toolbar” on page 291
Select a collapsed code fragment ❖ In Code view, click the collapsed code fragment.
Note: When you make a selection in Design view that is part of a collapsed code fragment, the fragment is automatically expanded in Code view. When you make a selection in Design view that is a complete code fragment, the fragment remains collapsed in Code view.
Last updated 3/28/2012
304
USING DREAMWEAVER Working with page code
View the code in a collapsed code fragment without expanding it ❖ Hold the mouse pointer over the collapsed code fragment.
Use keyboard shortcuts to collapse and expand code ❖ You can also use the following keyboard shortcuts: Command
Windows
Macintosh
Collapse Selection
Control+Shift+C
Command+Shift+C
Collapse Outside Selection
Control+Alt+C
Command+Alt+C
Expand Selection
Control+Shift+E
Command+Shift+E
Collapse Full Tag
Control+Shift+J
Command+Shift+J
Collapse Outside Full Tag
Control+Alt+J
Command+Alt+J
Expand All
Control+Alt+E
Command+Alt+E
Paste and move collapsed code fragments You can copy and paste collapsed code fragments, or move collapsed code fragments by dragging.
More Help topics “Insert code with the Coding toolbar” on page 291 “Clean up code” on page 305
Copy and paste a collapsed code fragment 1 Select the collapsed code fragment. 2 Select Edit > Copy. 3 Place the insertion point where you want to paste the code. 4 Select Edit > Paste.
Note: You can paste into other applications, but the collapsed state of the code fragment is not preserved.
Drag a collapsed code fragment 1 Select the collapsed code fragment. 2 Drag the selection to the new location.
To drag a copy of the selection, Control-drag (Windows) or Alt-drag (Macintosh). Note: You cannot drag to other documents.
Last updated 3/28/2012
305
USING DREAMWEAVER Working with page code
Optimizing and debugging code Clean up code You can automatically remove empty tags, combine nested font tags, and otherwise improve messy or unreadable HTML or XHTML code. For information on how to clean up HTML generated from a Microsoft Word document, see “Open and edit existing documents” on page 65. 1 Open a document:
• If the document is in HTML, select Commands > Clean Up HTML. • If the document is in XHTML, select Commands > Clean Up XHTML. For an XHTML document, the Clean Up XHTML command fixes XHTML syntax errors, sets the case of tag attributes to lowercase, and adds or reports the missing required attributes for a tag in addition to performing the HTML cleanup operations. 2 In the dialog box that appears, select any of the options, and click OK.
Note: Depending on the size of your document and the number of options selected, it may take several seconds to complete the cleanup. Remove Empty Container Tags Removes any tags that have no content between them. For example, and are empty tags, but the tag in some text is not.
Remove Redundant Nested Tags Removes all redundant instances of a tag. For example, in the code This is what I really wanted to say, the b tags surrounding the word really are redundant and would be removed.
Remove Non-Dreamweaver HTML Comments Removes all comments that were not inserted by Dreamweaver. For example, would be removed, but wouldn’t, because it’s a Dreamweaver comment that marks the beginning of an editable region in a template. Remove Dreamweaver Special Markup Removes comments that Dreamweaver adds to code to allow documents to be
automatically updated when templates and library items are updated. If you select this option when cleaning up code in a template-based document, the document is detached from the template. For more information, see “Detach a document from a template” on page 392. Remove Specific Tag(s) Removes the tags specified in the adjacent text box. Use this option to remove custom tags inserted by other visual editors and other tags that you don’t want to appear on your site (for example, blink). Separate multiple tags with commas (for example, font,blink). Combine Nested Tags When Possible Consolidates two or more font tags when they control the same range of
text. For example, big red would be changed to big red.
Show Log On Completion Displays an alert box with details about the changes made to the document as soon as the
cleanup is finished.
Last updated 3/28/2012
306
USING DREAMWEAVER Working with page code
More Help topics “Change the code format” on page 283 “Set the code colors” on page 285
Verify tags and braces are balanced You can check to make sure the tags, parentheses (( )), braces ({ }), and square brackets ([ ]) in your page are balanced. Balanced means that every opening tag, parenthesis, brace, or bracket has a corresponding closing one, and vice versa.
Check for balanced tags 1 Open the document in Code view. 2 Place the insertion point in the nested code you want to check. 3 Select Edit > Select Parent Tag.
The enclosing matching tags (and their contents) are selected in your code. If you keep selecting Edit > Select Parent Tag, and your tags are balanced, eventually Dreamweaver will select the outermost html and /html tags.
Check for balanced parentheses, braces, or square brackets 1 Open the document in Code view. 2 Place the insertion point in the code you want to check. 3 Select Edit > Balance Braces.
All of the code between the enclosing parentheses, braces, or square brackets is selected. Choosing Edit > Balance Braces again selects all of the code inside the parentheses, braces, or square brackets that enclose the new selection.
Check for browser compatibility The Browser Compatibility Check (BCC) feature helps you locate combinations of HTML and CSS that can trigger browser rendering bugs. This feature also tests the code in your documents for any CSS properties or values that are unsupported by your target browsers. Note: This feature replaces the former Target Browser Check feature, but retains the CSS functionality of that feature.
More Help topics “Check for cross-browser CSS rendering issues” on page 140
Validate XML documents You can set preferences for the Validator, the specific problems that the Validator should check for, and the types of errors that the Validator should report. 1 Do one of the following:
• For an XML or XHTML file, select File > Validate > As XML. • The Validation tab of the Results panel displays a “No errors or warnings” message or lists the syntax errors it found. 2 Double-click an error message to highlight the error in the document. 3 To save the report as an XML file, click the Save Report button.
Last updated 3/28/2012
307
USING DREAMWEAVER Working with page code
4 To view the report in your primary browser (which lets you print the report), click the Browse Report button.
Validate documents using W3C validator (CS5.5) Dreamweaver CS5.5 and later helps you create standards-compliant web pages with its in-built support for the W3C validator. The W3C validator validates your HTML documents for conformance to HTML or XHTML standards. You can validate both open documents, and files posted on a live server. Use the report that is generated after validation to fix errors in your file. Note: The W3C validator feature is available in Dreamweaver CS5.5 and later only. The previous version of the feature, available in Dreamweaver CS4, was deprecated for Dreamweaver CS5. See the Dreamweaver CS4 documentation for more information about the previous version of the feature.
Validate an open document 1 Select Window > Results > W3C validation. 2 Select File > Validate > Validate Current Document (W3C).
Validate a live document For live documents, Dreamweaver validates code received by the browser. This code is displayed when you right-click in your browser, and choose the option to view the source code. Validating live documents is especially useful when validating dynamic pages using PHP, JSP, and so on. The Validate Live Document option is enabled only when the URL of the page being validated begins with http. 1 Select Window > Results > W3C validation. 2 Click Live View. 3 Select File > Validate > Validate Live Document (W3C).
For live documents, when you double-click an error in the W3C validation panel, a separate window opens. The window displays the browser-generated code, and the line with the error is highlighted.
Customize validation settings 1 Select Window > Results > W3C validation. 2 In the W3C Validation panel, click the W3C Validation (Play) icon. Select Settings. 3 Select a DOCTYPE for validation if a DOCTYPE has not been explicitly specified for the document. 4 If you do not want errors and warnings displayed, clear the options. 5 Click Manage if you want to delete any warnings or errors that you have hidden using the W3C Validation panel.
When you remove warnings and errors, they are not displayed when you select Show All in the W3C validation panel. 6 Select Don't Show W3C Validator Notification Dialog if you do not want the W3C Validator Notification dialog
displayed when you begin validation.
Working with validation reports After validation is complete, the validation reports are displayed in the W3C Validation panel.
• For more information on the error or warning, select the error/warning in the W3C Validation panel. Click More Info. • To save the report as an XML file, click Save Report.
Last updated 3/28/2012
308
USING DREAMWEAVER Working with page code
• To view the entire report in HTML, click Browse Report. The HTML report provides the complete list of errors and warnings along with a summary.
• To jump to the location in the code containing the error, select the error in the W3C Validation panel. Click the Options button, and select Go to Line.
• To hide errors/warnings, select the error/warning. Click the Options button, and select Hide Error. • To view all the errors and warnings, including the hidden errors, click the Options button. Select Show All. Any hidden errors and warnings you deleted in the Preferences dialog are not listed.
• To clear all the results in the W3C validation panel, click the Options button. Select Clear Results.
Set Validator preferences The Validate tags feature has been deprecated as of Dreamweaver CS5. However, Dreamweaver still supports external code validators that you install as extensions. When you install an external validator extension, Dreamweaver lists its preferences in the Validator category of the Preferences dialog box. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Validator from the Category list on the left. 3 Select tag libraries to validate against.
You can’t select multiple versions of the same tag library or language; for example, if you select HTML 4.0, you can’t also select HTML 3.2 or HTML 2.0. Select the earliest version you want to validate against; for example, if a document contains valid HTML 2.0 code, it will also be valid HTML 4.0 code. 4 Click Options, and set options for those libraries. 5 Select Display options for the types of errors and warnings that you want the Validator report to include. 6 Select items the Validator should check for: Quotes In Text Indicates that Dreamweaver should warn you about each use of quotation marks in the text of the
document; you should use the " entity instead of quotation marks in the text of HTML documents. Entities In Text Indicates that Dreamweaver should recommend changing certain characters (such as ampersand (&),
less-than ()) to their HTML entity equivalents. 7 Click OK to close the Validator Options dialog box, and click OK again to set the preferences.
Make pages XHTML-compliant When you create a page, you can make it XHTML-compliant. You can also make an existing HTML document XHTML-compliant.
More Help topics “XHTML code” on page 277
Create XHTML-compliant documents 1 Select File > New. 2 Select a category and type of page to create. 3 Select one of the XHTML document type definitions (DTD) from the DocType pop-up menu on the far right of
the dialog box, and click Create.
Last updated 3/28/2012
309
USING DREAMWEAVER Working with page code
For example, you can make an HTML document XHTML-compliant by selecting XHTML 1.0 Transitional or XHTML 1.0 Strict from the pop-up menu. Note: Not all document types can be made XHTML-compliant.
Create XHTML-compliant documents by default 1 Select Edit > Preferences or Dreamweaver > Preferences (Mac OS X), and select the New Document category. 2 Select a default document and select one of the XHTML document type definitions from the Default Document
Type (DTD) pop-up menu, and click OK. For example, you can make an HTML document XHTML-compliant by selecting XHTML 1.0 Transitional or XHTML 1.0 Strict from the pop-up menu.
Make an existing HTML document XHTML-compliant 1 Open a document, and do one of the following:
• For a document without frames, select File > Convert, and then select one of the XHTML document type definitions. For example, you can make an HTML document XHTML-compliant by selecting XHTML 1.0 Transitional or XHTML 1.0 Strict from the pop-up menu.
• For a document with frames, select a frame and select File > Convert, and then select one of the XHTML document type definitions. 2 To convert the whole document, repeat this step for every frame and the frameset document.
Note: You can’t convert an instance of a template, because it must be in the same language as the template on which it’s based. For example, a document based on an XHTML template will always be in XHTML, and a document based on a non-XHTML-compliant HTML template will always be HTML and can’t be converted to XHTML or any other language.
Use the ColdFusion debugger (Windows only) If you’re a ColdFusion developer using ColdFusion as your Dreamweaver testing server, you can view ColdFusion debugging information without leaving Dreamweaver. Note: This feature is not supported on the Macintosh. Macintosh developers can use Preview In Browser (F12) to open a ColdFusion page in a separate browser. If the page contains errors, information about the possible causes for the errors appears at the bottom of the page. If you’re running ColdFusion MX 6.1 or earlier, make sure debugging settings are enabled in the ColdFusion Administrator before you begin debugging. If you’re running ColdFusion MX 7 or later, Dreamweaver enables the settings for you. Also, make sure your Dreamweaver testing server is running ColdFusion. For more information, see “Set up a testing server” on page 43. To ensure the debug information is refreshed every time a page is displayed in the internal browser, make sure Internet Explorer checks for newer versions of the file every time the file is requested. In Internet Explorer, select Tools > Internet Options, select the General tab, and click the Settings button in the Temporary Internet Files area. In the Settings dialog box, select the Every Visit to Page option. 1 Open the ColdFusion page in Dreamweaver. 2 Click the Server Debug icon
on the Document toolbar.
Last updated 3/28/2012
310
USING DREAMWEAVER Working with page code
Dreamweaver requests the page from the ColdFusion server and displays it in an internal Internet Explorer browser window. If the page contains errors, possible causes for the errors appear at the bottom of the page. At the same time, a Server Debug panel opens. The panel provides a large amount of useful information, such as all the pages the server processed to render the page, all the SQL queries executed on the page, and all the server variables and their values, if any. The panel also provides a summary of execution times. 3 If an Exceptions category appears in the Server Debug panel, click the Plus (+) icon to expand the category.
The Exceptions category appears if the server encountered a problem or problems with the page. Expand the category to find out more about the problem. 4 Switch back to Code view (View > Code) or Design view (View > Design) and fix the error. 5 Save the file and click the Server Debug icon again.
Dreamweaver renders the page in the internal browser again and updates the Server Debug panel. If there are no more problems with the page, the Exceptions category does not reappear in the panel. 6 To leave debug mode, switch to Code view (View > Code) or Design view (View > Design).
More Help topics “Using ColdFusion components” on page 616
Editing code in Design view About editing code in Design view Dreamweaver lets you visually create and edit web pages without worrying about the underlying source code, but there are times when you might need to edit the code for greater control or to troubleshoot your web page. Dreamweaver lets you edit some code while working in Design view. This section is designed for people who prefer to work in Design view, but who also want quick access to the code.
Selecting child tags in Design view If you select an object in Design view that contains child tags—for example, an HTML table—you can quickly select the first child tag of that object by selecting Edit > Select Child. Note: This command is only enabled in Design view. For example, the tag normally has child tags. If you select a tag in the tag selector, you can select the first row in the table by selecting Edit > Select Child. Dreamweaver selects the first tag in the tag selector. Since the tag itself has child tags, namely tags, selecting Edit > Select Child again selects the first cell in the table.
Edit code with the Property inspector You can use the Property inspector to inspect and edit the attributes of text or of objects on your page. The properties shown in the Property inspector generally correspond to attributes of tags; changing a property in the Property inspector generally has the same effect as changing the corresponding attribute in Code view.
Last updated 3/28/2012
311
USING DREAMWEAVER Working with page code
Note: The Tag inspector and the Property inspector both let you view and edit a tag’s attributes. The Tag inspector lets you to view and edit every attribute associated with a given tag. The Property inspector shows only the most common attributes, but provides a richer set of controls for changing those attributes’ values, and lets you edit certain objects (such as table columns) that don’t correspond to specific tags. 1 Click in the text or select an object on the page.
The Property inspector for the text or object appears below the Document window. If the Property inspector is not visible, select Window > Properties. 2 Make changes to the attributes in the Property inspector.
Edit CFML with the Property inspector Use the Property inspector to inspect and modify ColdFusion markup in Design view. 1 In the Property inspector, click the Attributes button to edit the tag’s attributes or to add new ones. 2 If the tag holds content between its opening and closing tags, click the Content button to edit the content.
The Content button appears only if the selected tag is not an empty tag (that is, if it has both an opening and a closing tag). 3 If the tag contains a conditional expression, make changes to it in the Expression box.
Change attributes with the Tag inspector Use the Tag inspector to edit or add attributes and attributes’ values. The Tag inspector lets you edit tags and objects by using a property sheet similar to the ones found in other integrated development environments (IDEs). 1 Do one of the following in the Document window:
• In Code view (or the Code inspector), click anywhere in a tag’s name or in its contents. • In Design view, select an object, or select a tag in the Tag Selector. 2 Open the Tag inspector (Window > Tag Inspector), and select the Attributes tab.
The selection’s attributes and their current values appear in the Tag inspector. 3 Do any of the following in the Tag inspector:
• To view the attributes organized by category, click the Show Category View button • To view the attributes in an alphabetical list, click the Show List View button
.
.
• To change the attribute’s value, select the value and edit it. • To add a value for an attribute with no value, click in the attribute-value column to the right of the attribute and add a value.
• If the attribute takes pre-defined values, select a value from the pop-up menu (or the color picker) to the right of the attribute-value column.
• If the attribute takes a URL value, click the Browse button or use the Point-To-File icon to select a file, or type the URL in the box.
• If the attribute takes a value from a source of dynamic content (such as a database), click the Dynamic Data button to the right of the attribute-value column. Then select a source.
• To delete the attribute’s value, select the value and press Backspace (Windows) or Delete (Macintosh). • To change the name of an attribute, select the attribute name and edit it.
Last updated 3/28/2012
312
USING DREAMWEAVER Working with page code
Note: If you change the name of a standard attribute and then add a value for that attribute, the attribute and its new value move to the appropriate category.
• To add a new attribute not already listed, click in the empty space below the last listed attribute name and type a new attribute name. 4 Press Enter (Windows) or Return (Macintosh), or click elsewhere in the Tag inspector, to update the tag in your
document.
More Help topics “Using JavaScript behaviors (general instructions)” on page 328 “Defining sources of dynamic content” on page 536
Quick Tag Editor overview You use the Quick Tag Editor to quickly inspect, insert, and edit HTML tags without leaving Design view. If you type invalid HTML in the Quick Tag Editor, Dreamweaver attempts to correct it for you by inserting closing quotation marks and closing angle brackets where needed. To set the Quick Tag Editor options, open the Quick Tag Editor by pressing Control-T (Windows) or Command-T (Macintosh). The Quick Tag Editor has three modes:
• Insert HTML mode is used to insert new HTML code. • Edit Tag mode is used to edit an existing tag. • Wrap Tag mode is to wrap a new tag around the current selection. Note: The mode in which the Quick Tag Editor opens depends on the current selection in Design view. In all three modes, the basic procedure for using the Quick Tag Editor is the same: open the editor, enter or edit tags and attributes, and then close the editor. You can cycle through the modes by pressing Control+T (Windows) or Command+T (Macintosh) while the Quick Tag Editor is active.
More Help topics “Use the hints menu in the Quick Tag Editor” on page 313
Edit code with the Quick Tag Editor Use the Quick Tag Editor to quickly insert and edit HTML tags without leaving Design view.
More Help topics “Write and edit scripts in Design view” on page 315
Insert an HTML tag 1 In Design view, click in the page to place the insertion point where you want to insert code. 2 Press Control+T (Windows) or Command+T (Macintosh).
Last updated 3/28/2012
313
USING DREAMWEAVER Working with page code
The Quick Tag Editor opens in Insert HTML mode.
3 Enter the HTML tag and press Enter.
The tag is inserted into your code, along with a matching closing tag if applicable. 4 Press Escape to exit without making any changes.
Edit an HTML tag 1 Select an object in Design view.
You can also select the tag you want to edit from the tag selector at the bottom of the Document window. For more information, see “Edit code with the tag selector” on page 314. 2 Press Control+T (Windows) or Command+T (Macintosh).
The Quick Tag Editor opens in Edit Tag mode. 3 Enter new attributes, edit existing attributes, or edit the tag’s name. 4 Press Tab to move forward from one attribute to the next; press Shift+Tab to move back.
Note: By default, changes are applied to the document when you press Tab or Shift+Tab. 5 To close the Quick Tag Editor and apply all the changes, press Enter. 6 To exit without making any further changes, press Escape.
Wrap the current selection with HTML tags 1 Select unformatted text or an object in Design view.
Note: If you select text or an object that includes an opening or closing HTML tag, the Quick Tag Editor opens in Edit Tag mode instead of Wrap Tag mode. 2 Press Control+T (Windows) or Command+T (Macintosh), or click the Quick Tag Editor button in the Property
inspector. The Quick Tag Editor opens in Wrap Tag mode. 3 Enter a single opening tag, such as strong, and press Enter (Windows) or Return (Macintosh).
The tag is inserted at the beginning of the current selection, and a matching closing tag is inserted at the end. 4 To exit without making any changes, press Escape.
Use the hints menu in the Quick Tag Editor The Quick Tag Editor includes an attributes hint menu that lists all the valid attributes of the tag you are editing or inserting. You can also disable the hints menu or adjust the delay before the menu pops up in the Quick Tag Editor. To see a hints menu that lists valid attributes for a tag, pause briefly while editing an attribute name in the Quick Tag Editor. A hints menu appears, listing all the valid attributes for the tag you’re editing.
Last updated 3/28/2012
314
USING DREAMWEAVER Working with page code
Similarly, to see a hints menu listing valid tag names, pause briefly while entering or editing a tag name in the Quick Tag Editor. Note: The Quick Tag Editor code hints preferences are controlled by the normal code hints preferences. For more information, see “Set code hints preferences” on page 289.
More Help topics “Quick Tag Editor overview” on page 312
Use a hints menu 1 Do one of the following:
• Begin to type a tag or attribute name. The selection in the Code Hints menu jumps to the first item that starts with the letters you typed.
• Use the Up and Down Arrow keys to select an item. • Use the scroll bar to find an item. 2 Press Enter to insert the selected item, or double-click an item to insert it. 3 To close the hints menu without inserting an item, press Escape or continue typing.
Disable the hints menu or change the delay before it appears 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh) and select Code Hints.
The Code Hints Preferences dialog box appears. 2 To disable the hints menu, deselect the Enable Code Hints option. 3 To change the delay before the menu appears, adjust the Delay slider, and click OK.
Edit code with the tag selector You can use the tag selector to select, edit, or remove tags without leaving Design view. The tag selector is located in the status bar at the bottom of the Document window and shows a series of tags, as follows:
Edit or delete a tag 1 Click in the document.
The tags that apply at the insertion point appear in the tag selector. 2 Right-click (Windows) or Control-click (Macintosh) a tag in the tag selector. 3 To edit a tag, select Edit Tag from the menu. Make your changes in the Quick Tag Editor. For more information,
see “Edit code with the Quick Tag Editor” on page 312. 4 To delete a tag, select Remove Tag from the menu.
Select an object corresponding to a tag 1 Click in the document.
The tags that apply at the insertion point appear in the tag selector. 2 Click a tag in the tag selector.
Last updated 3/28/2012
315
USING DREAMWEAVER Working with page code
The object represented by the tag is selected on the page. Use this technique to select individual table rows (tr tags) or cells (td tags).
Write and edit scripts in Design view You can work with client-side JavaScripts and VBScripts in both Code and Design views, in the following ways:
• Write a JavaScript or VBScript script for your page without leaving Design view. • Create a link in your document to an external script file without leaving Design view. • Edit a script without leaving Design view. Before starting, select View > Visual Aids > Invisible Elements to ensure that script markers appear on the page.
Write a client-side script 1 Place the insertion point where you want the script. 2 Select Insert > HTML > Script Objects > Script. 3 Select the scripting language from the Language pop-up menu.
If you are using JavaScript and are unsure of the version, select JavaScript rather than JavaScript1.1 or JavaScript1.2. 4 Type or paste your script code into the Content box.
You don’t need to include the opening and closing script tags. 5 Type or paste HTML code into the No Script box. Browsers that don’t support the chosen scripting language
display this code instead of running the script. 6 Click OK.
Link to an external script file 1 Place the insertion point where you want the script. 2 Select Insert > HTML > Script Objects > Script. 3 Click OK without typing anything in the Content box. 4 Select the script marker in Design view of the Document window. 5 In the Property inspector, click the folder icon and browse to and select the external script file, or type the filename
in the Source box.
Edit a script 1 Select the script marker. 2 In the Property inspector, click the Edit button.
The script appears in the Script Properties dialog box. If you linked to an external script file, the file opens in Code view, where you can make your edits. Note: If there is code between the script tags, the Script Properties dialog box opens even if there is also a link to an external script file. 3 In the Language box, specify either JavaScript or VBScript as the language of the script. 4 In the Type pop-up menu, specify the type of script, either client-side or server-side.
Last updated 3/28/2012
316
USING DREAMWEAVER Working with page code
5 (Optional) In the Source box, specify an externally linked script file.
Click the folder icon
or the Browse button to select a file, or type the path.
6 Edit the script, and click OK.
Edit ASP server-side scripts in Design view Use the ASP script Property inspector to inspect and modify ASP server-side scripts in Design view. 1 In Design view, select the server-language tag visual icon. 2 In the ASP script Property inspector, click the Edit button. 3 Edit the ASP server-side script, and click OK.
Edit scripts on the page by using the Property inspector 1 In the Property inspector, select the scripting language from the Language pop-up menu, or type a language name
in the Language box. Note: If you are using JavaScript and are unsure of the version, select JavaScript rather than JavaScript1.1 or JavaScript1.2. 2 In the Type pop-up menu, specify the type of script, either client-side or server-side. 3 (Optional) In the Source box, specify an externally linked script file. Click the folder icon
to select the file, or
type the path. 4 Click Edit to modify the script.
More Help topics “Write and edit scripts in Design view” on page 315
Using JavaScript behaviors You can easily attach JavaScript (client-side) behaviors to page elements by using the Behaviors tab of the Tag inspector. For more information, see “Applying built-in JavaScript behaviors” on page 331.
Working with head content for pages Pages contain elements that describe the information on the page, which is used by search browsers. You can set the properties of head elements to control how your pages are identified.
View and edit head content You can view the elements in the head section of a document by using the View menu, the Document window’s Code view, or the Code inspector.
View elements in the head section of a document ❖ Select View > Head Content. For each element of the head content, a marker appears at the top of the Document
window in Design view. Note: If your Document window is set to show only Code view, View > Head Content is dimmed.
Last updated 3/28/2012
317
USING DREAMWEAVER Working with page code
Insert an element into the head section of a document 1 Select an item from the Insert > HTML > Head Tags submenu. 2 Enter options for the element in the dialog box that appears, or in the Property inspector.
Edit an element in the head section of a document 1 Select View > Head Content. 2 Click one of the icons in the head section to select it. 3 Set or modify the properties of the element in the Property inspector.
Set the meta properties for the page A meta tag is a head element that records information about the current page, such as the character encoding, author, copyright, or keywords. These tags can also be used to give information to the server, such as the expiration date, refresh interval, and POWDER rating for the page. (POWDER, the Protocol for Web Description Resources, provides a method for assigning ratings, such as movie ratings, to web pages.)
Add a meta tag 1 Select Insert > HTML > Head Tags > Meta. 2 Specify the properties in the dialog box that appears.
Edit an existing meta tag 1 Select View > Head Content. 2 Select the Meta marker that appears at the top of the Document window. 3 Specify the properties in the Property inspector.
Meta tag properties ❖ Set the meta tag properties as follows: Attribute Specifies whether the meta tag contains descriptive information about the page (name) or HTTP header information (http-equiv). Value Specifies the type of information you’re supplying in this tag. Some values, such as description, keywords,
and refresh, are already well defined (and have their own individual Property inspectors in Dreamweaver), but you can specify practically any value (for example, creationdate, documentID, or level). Content Specifies the actual information. For example, if you specified level for Value, you might specify beginner, intermediate, or advanced for Content.
Set the page title There is only one title property: the title of the page. The title appears in the title bar of the Document window in Dreamweaver as well as in the browser’s title bar when you view the page in most browsers. The title also appears in the Document window toolbar.
Specify the title in the Document window ❖ Enter the title in the Title text box in the Document window toolbar.
Last updated 3/28/2012
318
USING DREAMWEAVER Working with page code
Specify the title in the head content 1 Select View > Head Content. 2 Select the Title marker that appears at the top of the Document window. 3 Specify the page title in the Property inspector.
Specify keywords for the page Many search-engine robots (programs that automatically browse the web gathering information for search engines to index) read the contents of the Keywords meta tag and use the information to index your pages in their databases. Because some search engines limit the number of keywords or characters they index, or ignore all keywords if you go beyond the limit, it’s a good idea to use just a few well-chosen keywords.
Add a Keywords meta tag 1 Select Insert > HTML > Head Tags > Keywords. 2 Specify the keywords, separated by commas, in the dialog box that appears.
Edit a Keywords meta tag 1 Select View > Head Content. 2 Select the Keywords marker that appears at the top of the Document window. 3 In the Property inspector, view, modify, or delete keywords. You can also add keywords separated by commas.
Specify descriptions for the page Many search-engine robots (programs that automatically browse the web gathering information for search engines to index) read the contents of the Description meta tag. Some use the information to index your pages in their databases, and some also display the information on the search results page (instead of displaying the first few lines of your document). Some search engines limit the number of characters they index, so it’s a good idea to limit your description to a few words (for example, Pork barbecue catering in Albany, Georgia, or Web design at reasonable rates for clients worldwide).
Add a Description meta tag 1 Select Insert > HTML > Head Tags > Description. 2 Enter descriptive text in the dialog box that appears.
Edit a Description meta tag 1 Select View > Head Content. 2 Select the Description marker that appears at the top of the Document window. 3 In the Property inspector, view, modify, or delete the descriptive text.
Set the refresh properties of the page Use the Refresh element to specify that the browser should automatically refresh your page—by reloading the current page or going to a different one—after a certain amount of time. This element is often used to redirect users from one URL to another, often after displaying a text message that the URL has changed.
Last updated 3/28/2012
319
USING DREAMWEAVER Working with page code
Add a Refresh meta tag 1 Select Insert > HTML > Head Tags > Refresh. 2 Set the Refresh meta tag properties in the dialog box that appears.
Edit a Refresh meta tag 1 Select View > Head Content. 2 Select the Refresh marker that appears at the top of the Document window. 3 In the Property inspector, set the Refresh meta tag properties.
Set the Refresh meta tag properties ❖ Specify the Refresh meta tag properties as follows: Delay The time in seconds to wait before the browser refreshes the page. To make the browser refresh the page
immediately after it finishes loading, enter 0 in this box. URL or Action Specifies whether the browser should go to a different URL or refresh the current page, after the specified delay. To make a different URL open (rather than refreshing the current page), click the Browse button, then browse to and select the page to load.
Set the base URL properties of the page Use the Base element to set the base URL that all document-relative paths in the page are considered relative to.
Add a Base meta tag 1 Select Insert > HTML > Head Tags > Base. 2 Specify the Base meta tag properties in the dialog box that appears.
Edit a Base meta tag 1 Select View > Head Content. 2 Select the Base marker that appears at the top of the Document window. 3 In the Property inspector, specify the Base meta tag properties.
Specify the Base meta tag properties ❖ Specify the Base meta tag properties as follows: Href The base URL. Click the Browse button to browse to and select a file, or type a path in the box. Target Specifies the frame or window in which all linked documents should open. Select one of the frames in the current frameset, or one of the following reserved names:
•
_blank loads the linked document in a new, unnamed browser window.
•
_parent loads the linked document into the parent frameset or window of the frame that contains the link. If the
frame containing the link is not nested, then this is equivalent to _top; the linked document loads into the full browser window.
•
_self loads the linked document in the same frame or window as the link. This target is the default, so you usually
don’t have to specify it.
•
_top loads the linked document in the full browser window, thereby removing all frames.
Last updated 3/28/2012
320
USING DREAMWEAVER Working with page code
Set the link properties of the page Use the link tag to define a relationship between the current document and another file. Note: The link tag in the head section is not the same thing as an HTML link between documents in the body section.
Add a Link meta tag 1 Select Insert > HTML > Head Tags > Link. 2 Specify the Link meta tag properties in the dialog box that appears.
Edit a Link meta tag 1 Select View > Head Content. 2 Select the Link marker that appears at the top of the Document window. 3 In the Property inspector, specify the Link meta tag properties.
Specify the Link meta tag properties ❖ Set the Link meta tag properties as follows: Href The URL of the file that you are defining a relationship to. Click the Browse button to browse to and select a file, or type a path in the box. Note that this attribute does not indicate a file that you’re linking to in the usual HTML sense; the relationships specified in a Link element are more complex. ID Specifies a unique identifier for the link. Title Describes the relationship. This attribute has special relevance for linked style sheets; for more information, see
the External Style Sheets section of the HTML 4.0 specification on the World Wide Web Consortium website at www.w3.org/TR/REC-html40/present/styles.html#style-external. Rel Specifies the relationship between the current document and the document in the Href box. Possible values
include Alternate, Stylesheet, Start, Next, Prev, Contents, Index, Glossary, Copyright, Chapter, Section, Subsection, Appendix, Help, and Bookmark. To specify more than one relationship, separate values with a space.
Rev Specifies a reverse relationship (the opposite of Rel) between the current document and the document in the Href
box. Possible values are the same as those for Rel.
Working with server-side includes About server-side includes You can use Dreamweaver to insert server-side includes in your pages, edit the includes, or preview pages containing includes. A server-side include is a file that the server incorporates into your document when a browser requests your document from the server.
Last updated 3/28/2012
321
USING DREAMWEAVER Working with page code
When a visitor’s browser requests the document that contains the include instruction, your server processes the include instruction and creates a new document in which the include instruction is replaced by the contents of the included file. The server then sends this new document to the visitor’s browser. When you open a local document directly in a browser, however, there’s no server to process the include instructions in that document, so the browser opens the document without processing those instructions, and the file that’s supposed to be included doesn’t appear in the browser. Thus, it can be difficult, without using Dreamweaver, to look at local files and see them as they’ll appear to visitors after you’ve put them on the server. With Dreamweaver you can preview documents just as they’ll appear after they’re on the server, both in the Design view and when you use the Preview in Browser feature. To do so, however, you must make sure you are previewing the file that contains the include as a temporary file. (Select Edit > Preferences, select the Preview in Browser category, and make sure the Preview using temporary file option is selected.) Note: If you are using a testing server, such as Apache or Microsoft IIS, to preview your files on your local drive, you do not need to preview the file as a temporary file because the server does the processing for you. Placing a server-side include in a document inserts a reference to an external file; it doesn’t insert the contents of the specified file in the current document. The contents of the specified file should only contain the content that you want to include. That is, the include file should not contain any head tags, body tags, or html tags (meaning the tag—formatting HTML tags, such as p tags, div tags, and so on, are fine). If it does, these tags will conflict with the tags in the original document, and Dreamweaver won’t display the page properly. You cannot edit the included file directly in a document. To edit the contents of a server-side include, you must directly edit the file that you’re including. Any changes to the external file are automatically reflected in every document that includes it. There are two types of server-side includes: Virtual and File. Dreamweaver inserts File type includes by default, but you can use the Property inspector to select the one that is appropriate for the type of web server you use:
• If your server is an Apache web server, select Virtual. In Apache, Virtual works in all cases, while File works only in some cases.
• If your server is a Microsoft Internet Information Server (IIS), select File. (Virtual works with IIS only in certain circumstances.) Note: Unfortunately, IIS won’t let you include a file in a folder above the current folder in the folder hierarchy, unless special software has been installed on the server. If you must include a file from a folder higher in the folder hierarchy on an IIS server, ask your system administrator if the necessary software is installed.
• For other kinds of servers, or if you don’t know what kind of server you’re using, ask your system administrator which option to use. Some servers are configured to examine all files to see if they contain server-side includes; other servers are configured to examine only files with a particular file extension, such as .shtml, .shtm, or .inc. If a server-side include isn’t working for you, ask your system administrator if you need to use a special extension in the name of the file that uses the include. (For example, if the file is named canoe.html, you may have to rename it to canoe.shtml.) If you want your files to retain .html or .htm extensions, ask your system administrator to configure the server to examine all files (not just files with a certain extension) for server-side includes. Parsing a file for server-side includes takes a little extra time, so pages that the server parses are served a little more slowly than other pages; therefore, some system administrators won’t provide the option of parsing all files.
Insert server-side includes You can use Dreamweaver to insert server-side includes in your page.
Last updated 3/28/2012
322
USING DREAMWEAVER Working with page code
Insert a server-side include 1 Select Insert > Server-Side Include. 2 In the dialog box that appears, browse to and select a file.
By default, a File type of include is inserted. 3 To change the type of the include, select the server-side include in the Document window and change the type in
the Property inspector (Window > Properties), as follows:
• If your server is an Apache web server, select Virtual. In Apache, Virtual works in all cases, while File works only in some cases.
• If your server is a Microsoft Internet Information Server (IIS), select File. (Virtual works with IIS only in certain specific circumstances.) Note: Unfortunately, IIS won’t allow you to include a file in a folder above the current folder in the folder hierarchy, unless special software has been installed on the server. If you need to include a file from a folder higher in the folder hierarchy on an IIS server, ask your system administrator if the necessary software is installed.
• For other kinds of servers, or if you don’t know what kind of server you’re using, ask your system administrator which option to use.
Change which file is included 1 Select the server-side include in the Document window. 2 Open the Property inspector (Window > Properties). 3 Do one of the following:
• Click the folder icon and browse to and select a new file to include. • In the box, type the path and filename of the new file to include.
Edit the contents of server-side includes You can use Dreamweaver to edit server-side includes. To edit the content associated with the included file, you must open the file. 1 Select the server-side include in either Design view or Code view, and click Edit in the Property inspector.
The included file opens in a new Document window. 2 Edit the file, and then save it.
The changes are immediately reflected in the current document and in any subsequent document you open that includes the file. 3 Upload the include file to the remote site if necessary.
Last updated 3/28/2012
323
USING DREAMWEAVER Working with page code
Managing tag libraries About Dreamweaver tag libraries A tag library, in Dreamweaver, is a collection of tags of a particular type, along with information about how Dreamweaver should format the tags. Tag libraries provide the information about tags that Dreamweaver uses for code hints, target browser checks, the Tag Chooser, and other coding capabilities. Using the Tag Library editor, you can add and delete tag libraries, tags, attributes, and attribute values; set properties for a tag library, including format (for easy identification in the code); and edit tags and attributes.
More Help topics “Importing custom tags into Dreamweaver” on page 325 “Setting coding preferences” on page 282
Open and close the Tag Library editor 1 Select Edit >Tag Libraries to open the Tag library editor.
The Tag Library Editor dialog box appears. (The options of this dialog box change depending on the selected tag.) 2 Close the Tag Library editor in one of the following ways:
• To save changes, click OK. • To close the editor without saving changes, click Cancel. Note: When you click Cancel, all changes you’ve made in the Tag Library editor are discarded. If you deleted a tag or tag library, it’s restored.
Add libraries, tags, and attributes You can use the Tag Library editor to add tag libraries, tags, and attributes to the tag libraries in Dreamweaver.
More Help topics “Setting coding preferences” on page 282 “Importing custom tags into Dreamweaver” on page 325
Add a tag library 1 In the Tag Library editor (Edit > Tag Libraries), click the Plus (+) button, and select New Tag Library. 2 In the Library Name box, type a name (for example, Miscellaneous Tags), and click OK.
Add tags to a tag library 1 In the Tag Library editor (Edit > Tag Libraries), click the Plus (+) button and select New Tags. 2 Select Tag Library pop-up menu, and select a tag library. 3 Type the name of the new tag. To add more than one tag, separate the tags’ names with a comma and a space (for
example: cfgraph, cfgraphdata). 4 If the new tags have corresponding end tags (), select Have Matching End Tags. 5 Click OK.
Last updated 3/28/2012
324
USING DREAMWEAVER Working with page code
Add attributes to a tag 1 In the Tag Library editor (Edit > Tag Libraries), click the Plus (+) button and select New Attributes. 2 In the Tag Library pop-up menu, select a tag library. 3 In the Tag pop-up menu, select a tag. 4 Type the name of the new attribute. To add more than one attribute, separate attributes’ names with a comma and
a space (for example: width, height). 5 Click OK.
Edit libraries, tags, and attributes Use the Tag Library editor to set properties for a tag library and edit tags and attributes in a library.
More Help topics “Setting coding preferences” on page 282
Set properties for a tag library 1 In the Tag Library editor (Edit > Tag Libraries), select a tag library (not a tag) in the Tags list.
Note: The properties for tag libraries appear only when a tag library is selected. Tag libraries are represented by the toplevel folders in the Tags list; for example, the HTML Tags folder represents a tag library, while the abbr folder within the HTML Tags folder represents a tag. 2 In the Used In list, select every document type that should use the tag library.
The document types you select here determine which document types provide code hints for the given tag library. For example, if the HTML option is not selected for a given tag library, code hints for that tag library don’t appear in HTML files. 3 (Optional) Enter the prefix for the tags in the Tag Prefix box.
Note: A prefix is used to identify a tag in the code as part of a particular tag library. Some tag libraries don’t use prefixes. 4 Click OK.
Edit a tag in a tag library 1 In the Tag Library editor (Edit > Tag Libraries), expand a tag library in the Tags list and select a tag. 2 Set any of the following Tag Format options: Line Breaks Specifies where Dreamweaver inserts line breaks for a tag. Contents Specifies how Dreamweaver inserts the contents of a tag; that is, if it applies line break, formatting, and
indentation rules to the content. Case Specifies the case for a specific tag. Select from Default, Lowercase, Uppercase, or Mixed Case. If you select Mixed
Case, the Tag Name Mixed Case dialog box appears. Type the tag with the case Dreamweaver should use when inserting it (for example, getProperty) and click OK. Set Default Sets the default case for all tags. In the Default Tag Case dialog box that appears, select or , and click OK.
You might want to set your default case to be lowercase to comply with XML and XHTML standards.
Last updated 3/28/2012
325
USING DREAMWEAVER Working with page code
Edit an attribute for a tag 1 In the Tag Library editor (Edit > Tag Libraries), expand a tag library in the Tags box, expand a tag, and select a tag
attribute. 2 In the Attribute Case pop-up menu, select the Default, Lowercase, Uppercase, or Mixed Case option.
If you select Mixed Case, the Attribute Name Mixed Case dialog box appears. Type the attribute with the case Dreamweaver should use when inserting it (for example, onClick), and click OK. Click the Set Default link to set the default case for all attribute names. 3 In the Attribute Type pop-up menu, select the type of the attribute.
If you select Enumerated, type every allowed value for the attribute in the Values box. Separate the values with commas, but no spaces. For example, the enumerated values of the showborder attribute of the cfchart tag are listed as yes,no.
Delete libraries, tags, and attributes 1 In the Tag Library editor (Edit > Tag Libraries), select a tag library, tag, or attribute in the Tags box. 2 Click the Minus (–) button. 3 Click OK to permanently delete the item.
The item is removed from the Tags box. 4 Click OK to close the Tag Library editor and complete the deletion.
More Help topics “Setting coding preferences” on page 282
Importing custom tags into Dreamweaver About importing custom tags into Dreamweaver You can import custom tags into Dreamweaver so that they become an integral part of the authoring environment. For example, when you start typing an imported custom tag in Code view, a code hints menu appears, listing the tag’s attributes and letting you select one.
Import tags from XML files You can import tags from an XML Document Type Definition (DTD) file or a schema. 1 Open the Tag Library editor (Edit > Tag Libraries). 2 Click the Plus (+) button and select DTD Schema > Import XML DTD or Schema File. 3 Enter the filename or URL of the DTD or schema file. 4 Enter the prefix to be used with the tags.
Note: A prefix is used to identify a tag in the code as part of a particular tag library. Some tag libraries don’t use prefixes.
Last updated 3/28/2012
326
USING DREAMWEAVER Working with page code
5 Click OK.
Import custom ASP.NET tags You can import custom ASP.NET tags into Dreamweaver. Before you begin, make sure that the custom tag is installed on the testing server defined in the Site Definition dialog box (see “Set up a testing server” on page 43). Compiled tags (DLL files) must be placed in the site root’s /bin folder. Noncompiled tags (ASCX files) can reside in any virtual directory or subdirectory on the server. For more information, see the Microsoft ASP.NET documentation. 1 Open an ASP.NET page in Dreamweaver. 2 Open the Tag Library editor (Edit > Tag Libraries). 3 Click the Plus (+) button, select one of the following options, and click OK:
• To import all the ASP.NET custom tags from the application server, select ASP.NET > Import All ASP.NET Custom Tags.
• To import only certain custom tags from the application server, select ASP.NET > Import Selected ASP.NET Custom Tags. Control-click (Windows) or Command-click (Macintosh) tags from the list.
Import JSP tags from a file or server (web.xml) Import a JSP tag library into Dreamweaver from a variety of file types or a JSP server. 1 Open a JSP page in Dreamweaver. 2 Open the Tag Library editor (Edit > Tag Libraries). 3 Click the Plus (+) button, and select JSP > Import From File (*.tld, *.jar, *.zip), or JSP > Import from Server
(web.xml.) 4 Click the Browse button or enter a filename for the file that contains the tag library. 5 Enter a URI to identify the tag library.
The URI (Uniform Resource Identifier) often consists of the URL of the organization maintaining the tag library. The URL is not used to view the organization’s website; it is used to uniquely identify the tag library. 6 (Optional) Enter the prefix to be used with the tags. Some tag libraries use a prefix to identify a tag in the code as
part of a particular tag library. 7 Click OK.
Import JRun tags If you use Adobe® JRun™, you can import your JRun tags into Dreamweaver. 1 Open a JSP page in Dreamweaver. 2 Open the Tag Library editor (Edit > Tag Libraries). 3 Click the Plus (+) button and select JSP > Import JRun Server Tags From Folder. 4 Enter a folder name for the folder that contains the JRun tags. 5 Enter a URI to identify the tag library.
Last updated 3/28/2012
327
USING DREAMWEAVER Working with page code
The URI (Uniform Resource Identifier) often consists of the URL of the organization maintaining the tag library. The URL is not used to view the organization’s website; it is used to uniquely identify the tag library. 6 (Optional) Enter the prefix to be used with the tags. Some tag libraries use a prefix to identify a tag in the code as
part of a particular tag library. 7 Click OK.
Last updated 3/28/2012
328
Chapter 12: Adding JavaScript behaviors Using JavaScript behaviors (general instructions) About JavaScript behaviors Adobe® Dreamweaver® CS5 behaviors place JavaScript code in documents so that visitors can change a web page in various ways or initiate certain tasks. A behavior is a combination of an event and an action triggered by that event. In the Behaviors panel, you add a behavior to a page by specifying an action and then specifying the event that triggers that action. Note: Behavior code is client-side JavaScript code; that is, it runs in browsers, not on servers. Events are, effectively, messages generated by browsers indicating that a visitor to your page has done something. For example, when a visitor moves the pointer over a link, the browser generates an onMouseOver event for that link; the browser then checks whether it should call some JavaScript code (specified in the page being viewed) in response. Different events are defined for different page elements; for example, in most browsers onMouseOver and onClick are events associated with links, whereas onLoad is an event associated with images and with the body section of the document. An action is pre-written JavaScript code for performing a task, such as opening a browser window, showing or hiding an AP element, playing a sound, or stopping an Adobe Shockwave movie. The actions provided with Dreamweaver provide maximum cross-browser compatibility. After you attach a behavior to a page element, the behavior calls the action (JavaScript code) associated with an event whenever that event occurs for that element. (The events that you can use to trigger a given action vary from browser to browser.) For example, if you attach the Popup Message action to a link and specify that it will be triggered by the onMouseOver event, then your message pops up whenever someone places the pointer over that link. A single event can trigger several different actions, and you can specify the order in which those actions occur. Dreamweaver provides about two dozen actions; additional actions can be found on the Exchange website at www.adobe.com/go/dreamweaver_exchange as well as on third-party developer sites. You can write your own actions if you are proficient in JavaScript. Note: The terms behavior and action are Dreamweaver terms, not HTML terms. From the browser’s point of view, an action is just like any other piece of JavaScript code.
Behaviors panel overview You use the Behaviors panel (Window > Behaviors) to attach behaviors to page elements (more specifically to tags) and to modify parameters of previously attached behaviors. Behaviors that have already been attached to the currently selected page element appear in the behavior list (the main area of the panel), listed alphabetically by event. If several actions are listed for the same event, they will be executed in the order in which they appear on the list. If no behaviors appear in the behavior list, no behaviors have been attached to the currently selected element. The Behaviors panel has the following options: Show Set Events Displays only those events that have been attached to the current document. Events are organized into
client-side and server-side categories. Each category’s events are in a collapsible list. Show Set Events is the default view.
Last updated 3/28/2012
329
USING DREAMWEAVER Adding JavaScript behaviors
Show All Events Displays an alphabetical list of all events for a given category. Add Behavior (+) Displays a menu of actions that can be attached to the currently selected element. When you select
an action from this list, a dialog box appears in which you can specify parameters for the action. If all the actions are dimmed, no events can be generated by the selected element. Remove Event (–) Removes the selected event and action from the behavior list. Up and down arrow buttons Move the selected action up or down in the behavior list for a particular event. You can
change the order of actions only for a particular event—for example, you can change the order in which several actions occur for the onLoad event, but all the onLoad actions stay together in the behavior list. The arrow buttons are disabled for actions that can’t be moved up or down in the list. Events Displays a pop-up menu, visible only when an event is selected, of all the events that can trigger the action (this
menu appears when you click the arrow button next to the selected event name). Different events appear depending on the object selected. If the events you expect don’t appear, make sure that the correct page element or tag is selected. (To select a specific tag, use the tag selector at the lower-left corner of the Document window.) Note: Event names in parentheses are available only for links; selecting one of these event names automatically adds a null link to the selected page element, and attaches the behavior to that link instead of to the element itself. The null link is specified as href="javascript:;" in the HTML code.
About events Each browser provides a set of events that you can associate with the actions listed in the Behavior panel’s Actions (+) menu. When a visitor to your web page interacts with the page—for example, by clicking an image—the browser generates events; those events can be used to call JavaScript functions that perform an action. Dreamweaver supplies many common actions that you can trigger with these events. For names and descriptions of the events provided by each browser, see the Dreamweaver Support Center at www.adobe.com/go/dreamweaver_support. Different events appear in the Events menu depending on the selected object. To find out what events a given browser supports for a given page element, insert the page element in your document and attach a behavior to it, then look at the Events menu in the Behaviors panel. (By default, events are drawn from the HTML 4.01 events list, and are supported by most modern browsers.) Events may be disabled (dimmed) if the relevant objects do not yet exist on the page or if the selected object cannot receive events. If the expected events don’t appear, make sure the correct object is selected. If you’re attaching a behavior to an image, some events (such as onMouseOver) appear in parentheses. These events are available only for links. When you select one of them, Dreamweaver wraps an tag around the image to define a null link. The null link is represented by javascript:; in the Property inspector’s Link box. You can change the link value if you want to turn it into a real link to another page, but if you delete the JavaScript link without replacing it with another link, you will remove the behavior. To see which tags you can use with a given event in a given browser, search for the event in one of the files in the Dreamweaver/Configuration/Behaviors/Events folder.
Apply a behavior You can attach behaviors to the entire document (that is, to the tag) or to links, images, form elements, and several other HTML elements. The target browser you select determines which events are supported for a given element.
Last updated 3/28/2012
330
USING DREAMWEAVER Adding JavaScript behaviors
You can specify more than one action for each event. Actions occur in the order in which they’re listed in the Actions column of the Behaviors panel, but you can change that order. 1 Select an element on the page, such as an image or a link.
To attach a behavior to the entire page, click the tag in the tag selector at the lower-left corner of the Document window. 2 Choose Window > Behaviors. 3 Click the Plus (+) button and select an action from the Add Behavior menu.
Actions that are dimmed in the menu can’t be chosen. They may be dimmed because a required object doesn’t exist in the current document. For example, the Control Shockwave or SWF action is dimmed if the document contains no Shockwave or SWF files. When you select an action, a dialog box appears, displaying parameters and instructions for the action. 4 Enter parameters for the action, and click OK.
All actions provided in Dreamweaver work in modern browsers. Some actions do not work in older browsers, but they will not cause errors. Note: Targeted elements require a unique ID. For example, if you want to apply the Swap Image behavior to an image, the image requires an ID. If you don’t have an ID specified for the element, Dreamweaver automatically specifies one for you. 5 The default event to trigger the action appears in the Events column. If this is not the trigger event you want, select
another event from the Events pop-up menu. (To open the Events menu, select an event or action in the Behaviors panel, and click the downward-pointing black arrow that appears between the event name and the action name.)
Change or delete a behavior After attaching a behavior, you can change the event that triggers the action, add or remove actions, and change parameters for actions. 1 Select an object with a behavior attached. 2 Choose Window > Behaviors. 3 Make your changes:
• To edit an action’s parameters, double-click its name, or select it and press Enter (Windows) or Return (Macintosh); then change parameters in the dialog box and click OK.
• To change the order of actions for a given event, select an action and click the Up or Down arrow. Alternatively, you can select the action and cut and paste it into the desired location among the other actions.
• To delete a behavior, select it and click the Minus (–) button or press Delete.
Update a behavior 1 Select an element that has the behavior attached to it. 2 Choose Window > Behaviors and double-click the behavior. 3 Make your changes and click OK in the behavior’s dialog box.
All occurrences of that behavior in that page are updated. If other pages on your site have that behavior, you must update them page by page.
Last updated 3/28/2012
331
USING DREAMWEAVER Adding JavaScript behaviors
Download and install third-party behaviors Many extensions are available on the Exchange for Dreamweaver website (www.adobe.com/go/dreamweaver_exchange). 1 Choose Window > Behaviors and select Get More Behaviors from the Add Behavior menu.
Your primary browser opens, and the Exchange site appears. 2 Browse or search for packages. 3 Download and install the extension package you want.
For more information, see “Add and manage extensions in Dreamweaver” on page 33.
Applying built-in JavaScript behaviors Using built-in behaviors The behaviors included with Dreamweaver have been written to work in modern browsers. The behaviors fail silently in older browsers. Note: The Dreamweaver actions have been carefully written to work in as many browsers as possible. If you remove code from a Dreamweaver action by hand, or replace it with your own code, you may lose cross-browser compatibility. Although the Dreamweaver actions were written to maximize cross-browser compatibility, some browsers do not support JavaScript at all, and many people who browse the web keep JavaScript turned off in their browsers. For best cross-platform results, provide alternative interfaces enclosed in tags so that people without JavaScript can use your site.
Apply the Call JavaScript behavior The Call JavaScript behavior executes a custom function or line of JavaScript code when an event occurs. (You can write the script yourself, or you can use code provided by various freely available JavaScript libraries on the web.) 1 Select an object and choose Call JavaScript from the Add Behavior menu of the Behaviors panel. 2 Type the exact JavaScript to be executed, or type the name of a function.
For example, to create a Back button, you might type if (history.length > 0){history.back()}. If you have encapsulated your code in a function, type only the function name (for example, hGoBack()). 3 Click OK and verify that the default event is correct.
Apply the Change Property behavior Use the Change Property behavior to change the value of one of an object’s properties (for example, the background color of a div or the action of a form). Note: Use this behavior only if you are very familiar with HTML and JavaScript. 1 Select an object and choose Change Property from the Add Behavior menu of the Behaviors panel. 2 From the Type Of Element menu, select an element type to display all the identified elements of that type. 3 Select an element from the Element ID menu. 4 Select a property from the Property menu, or enter the name of the property in the box.
Last updated 3/28/2012
332
USING DREAMWEAVER Adding JavaScript behaviors
5 Enter the new value for the new property in the New Value field. 6 Click OK and verify that the default event is correct.
Apply the Check Browser behavior This behavior has been deprecated as of Dreamweaver CS5.
Apply the Check Plugin behavior Use the Check Plugin behavior to send visitors to different pages depending on whether they have the specified plug-in installed. For example, you might want visitors to go to one page if they have Shockwave and another page if they do not. Note: You cannot detect specific plug-ins in Internet Explorer using JavaScript. However, selecting Flash or Director will add the appropriate VBScript code to your page to detect those plug-ins in Internet Explorer on Windows. Plug-in detection is impossible in Internet Explorer on Mac OS. 1 Select an object and choose Check Plugin from the Add Behavior menu of the Behaviors panel. 2 Select a plug-in from the Plugin menu, or click Enter and type the exact name of the plug-in in the adjacent box.
You must use the exact name of the plug-in as specified in bold on the About Plug-ins page in Netscape Navigator. (In Windows, select Navigator’s Help > About Plug-ins command; on Mac OS, select About Plug-ins from the Apple menu.) 3 In the If Found, Go To URL box, specify a URL for visitors who have the plug-in.
If you specify a remote URL, you must include the http:// prefix in the address. If you leave the field blank, visitors will stay on the same page. 4 In the Otherwise, Go To URL box, specify an alternative URL for visitors who don’t have the plug-in. If you leave
the field blank, visitors will stay on the same page. 5 Specify what to do if plug-in detection is not possible. By default, when detection is impossible, the visitor is sent to
the URL listed in the Otherwise box. To instead send the visitor to the first (If Found) URL, select the option Always Go To First URL If Detection Is Not Possible. When selected, this option effectively means “assume that the visitor has the plug-in, unless the browser explicitly indicates that the plug-in is not present.” In general, select this option if the plug-in content is integral to your page; if not leave it deselected. Note: This option applies only to Internet Explorer; Netscape Navigator can always detect plug-ins. 6 Click OK and verify that the default event is correct.
Apply the Control Shockwave or SWF behavior This behavior has been deprecated as of Dreamweaver CS5.
Apply the Drag AP Element behavior The Drag AP Element behavior lets the visitor drag an absolutely positioned (AP) element. Use this behavior to create puzzles, slider controls, and other movable interface elements. You can specify in which direction the visitor can drag the AP element (horizontally, vertically, or in any direction), a target to which the visitor should drag the AP element, whether to snap the AP element to the target if the AP element is within a certain number of pixels of the target, what to do when the AP element hits the target, and more.
Last updated 3/28/2012
333
USING DREAMWEAVER Adding JavaScript behaviors
Because the Drag AP Element behavior must be called before the visitor can drag the AP element, you should attach Drag AP Element to the body object (with the onLoad event). 1 Select Insert > Layout Objects > AP Div or click the Draw AP Div button on the Insert panel and draw an AP Div
in the Document window’s Design view. 2 Click in the tag selector at the lower-left corner of the Document window. 3 Select Drag AP Element from the Add Behavior menu of the Behaviors panel.
If Drag AP Element is unavailable, you probably have an AP element selected. 4 In the AP Element pop-up menu, select the AP element. 5 Select either Constrained or Unconstrained from the Movement pop-up menu.
Unconstrained movement is appropriate for puzzles and other drag-and-drop games. For slider controls and moveable scenery such as file drawers, curtains, and mini-blinds, select constrained movement. 6 For constrained movement, enter values (in pixels) in the Up, Down, Left, and Right boxes.
Values are relative to the starting position of the AP element. To constrain movement within a rectangular region, enter positive values in all four boxes. To allow only vertical movement, enter positive values for Up and Down and 0 for Left and Right. To allow only horizontal movement, enter positive values for Left and Right and 0 for Up and Down. 7 Enter values (in pixels) for the drop target in the Left and Top boxes.
The drop target is the spot to which you want the visitor to drag the AP element. An AP element is considered to have reached the drop target when its left and top coordinates match the values you enter in the Left and Top boxes. Values are relative to the top left corner of the browser window. Click Get Current Position to automatically fill the text boxes with the current position of the AP element. 8 Enter a value (in pixels) in the Snap If Within box to determine how close the visitor must get to the drop target
before the AP element snaps to the target. Larger values make it easier for the visitor to find the drop target. 9 For simple puzzles and scenery manipulation, you can stop here. To define the drag handle for the AP element,
track the movement of the AP element while it is being dragged, and trigger an action when the AP element is dropped, click the Advanced tab. 10 To specify that the visitor must click a particular area of the AP element to drag the AP element, select Area within
element from the Drag Handle menu; then enter the left and top coordinates and the width and height of the drag handle. This option is useful when the image inside the AP element contains an element that suggests dragging, such as a title bar or drawer handle. Do not set this option if you want the visitor to be able to click anywhere in the AP element to drag it. 11 Select any While Dragging options that you want to use:
• Select Bring Element To Front if the AP element should move to the front of the stacking order while it is being dragged. If you select this option, use the pop-up menu to select whether to leave the AP element in front or restore it to its original position in the stacking order.
• Enter JavaScript code or a function name (for example, monitorAPelement()) in the Call JavaScript box to repeatedly execute the code or function while the AP element is being dragged. For example, you could write a function that monitors the coordinates of the AP element and displays hints such as “you’re getting warmer” or “you’re nowhere near the drop target” in a text box.
Last updated 3/28/2012
334
USING DREAMWEAVER Adding JavaScript behaviors
12 Enter JavaScript code or a function name (for example, evaluateAPelementPos()) in the second Call JavaScript
box to execute the code or function when the AP element is dropped. Select Only If Snapped if the JavaScript should be executed only if the AP element has reached the drop target. 13 Click OK and verify that the default event is correct.
Gathering information about the draggable AP element When you attach the Drag AP element behavior to an object, Dreamweaver inserts the MM_dragLayer() function into the head section of your document. (The function retains the old naming convention for AP elements [that is, “Layer”] so that layers created in previous versions of Dreamweaver will remain editable.) In addition to registering the AP element as draggable, this function defines three properties for each draggable AP element—MM_LEFTRIGHT, MM_UPDOWN, and MM_SNAPPED—that you can use in your own JavaScript functions to determine the relative horizontal position of the AP element, the relative vertical position of the AP element, and whether the AP element has reached the drop target. Note: The information provided here is intended for experienced JavaScript programmers only. For example, the following function displays the value of the MM_UPDOWN property (the current vertical position of the AP element) in a form field called curPosField. (Form fields are useful for displaying continuously updated information because they are dynamic—that is, you can change their contents after the page has finished loading.) function getPos(layerId){ var layerRef = document.getElementById(layerId); var curVertPos = layerRef.MM_UPDOWN; document.tracking.curPosField.value = curVertPos; }
Instead of displaying the values of MM_UPDOWN or MM_LEFTRIGHT in a form field, you could use those values in a variety of other ways. For example, you could write a function that displays a message in the form field depending on how close the value is to the drop zone, or you could call another function to show or hide an AP element depending on the value. It is especially useful to read the MM_SNAPPED property when you have several AP elements on the page, all of which must reach their targets before the visitor can advance to the next page or task. For example, you could write a function to count how many AP elements have an MM_SNAPPED value of true and call it whenever an AP element is dropped. When the snapped count reaches the desired number, you could send the visitor to the next page or display a message of congratulations.
Apply the Go To URL behavior The Go To URL behavior opens a new page in the current window or in the specified frame. This behavior is useful for changing the contents of two or more frames with one click. 1 Select an object and choose Go To URL from the Add Behavior menu of the Behaviors panel. 2 Select a destination for the URL from the Open In list.
The Open In list automatically lists the names of all frames in the current frameset as well as the main window. If there are no frames, the main window is the only option. Note: This behavior may produce unexpected results if any frame is named top, blank, self, or parent. Browsers sometimes mistake these names for reserved target names. 3 Click Browse to select a document to open, or enter the path and filename of the document in the URL box. 4 Repeat steps 2 and 3 to open additional documents in other frames.
Last updated 3/28/2012
335
USING DREAMWEAVER Adding JavaScript behaviors
5 Click OK and verify that the default event is correct.
Apply the Jump Menu behavior When you create a jump menu by using Insert > Form > Jump Menu, Dreamweaver creates a menu object and attaches the Jump Menu (or Jump Menu Go) behavior to it. There is usually no need to attach the Jump Menu behavior to an object by hand. You can edit an existing jump menu in either of two ways:
• You can edit and rearrange menu items, change the files to jump to, and change the window in which those files open, by double-clicking an existing Jump Menu behavior in the Behaviors panel.
• You can edit the items in the menu just as you would edit items in any menu, by selecting the menu and using the List Values button in the Property inspector. 1 Create a jump menu object if there isn’t one already in your document. 2 Select the object and choose Jump Menu from the Add Behavior menu of the Behaviors panel. 3 Make changes as desired in the Jump Menu dialog box and then click OK.
More Help topics “Jump menus” on page 266 “Insert or change a dynamic HTML form menu” on page 634
Apply the Jump Menu Go behavior The Jump Menu Go behavior is closely associated with the Jump Menu behavior; Jump Menu Go lets you associate a Go button with a jump menu. (Before you use this behavior, a jump menu must already exist in the document.) Clicking the Go button opens the link that’s selected in the jump menu. A jump menu doesn’t normally need a Go button; selecting an item from a jump menu generally causes a URL to load without any need for further user action. But if the visitor selects the same item that’s already chosen in the jump menu, the jump doesn’t occur. In general, that doesn’t matter, but if the jump menu appears in a frame, and the jump menu items link to pages in other frames, a Go button is often useful, to allow visitors to re-select an item that’s already selected in the jump menu. Note: When you use a Go button with a jump menu, the Go button becomes the only mechanism that “jumps” the user to the URL associated with the selection in the menu. Selecting a menu item in the jump menu no longer re-directs the user automatically to another page or frame. 1 Select an object to use as the Go button (generally a button image), and choose Jump Menu Go from the Add
Behavior menu of the Behaviors panel. 2 In the Choose Jump Menu menu, select a menu for the Go button to activate and click OK.
Apply the Open Browser Window behavior Use the Open Browser Window behavior to open a page in a new window. You can specify the properties of the new window, including its size, attributes (whether it is resizable, has a menu bar, and so on), and name. For example, you can use this behavior to open a larger image in a separate window when the visitor clicks a thumbnail image; with this behavior, you can make the new window the exact size of the image.
Last updated 3/28/2012
336
USING DREAMWEAVER Adding JavaScript behaviors
If you specify no attributes for the window, it opens at the size and with the attributes of the window from which it was opened. Specifying any attribute for the window automatically turns off all other attributes that are not explicitly turned on. For example, if you set no attributes for the window, it might open at 1024 x 768 pixels and have a navigation bar (showing the Back, Forward, Home and Reload buttons), location toolbar (showing the URL), status bar (showing status messages, at the bottom), and menu bar (showing File, Edit, View and other menus). If you explicitly set the width to 640 and the height to 480 and set no other attributes, the window opens at 640 x 480 pixels, without toolbars. 1 Select an object and choose Open Browser Window from the Add Behavior menu of the Behaviors panel. 2 Click Browse to select a file, or enter the URL you want to display. 3 Set the options for window width and height (in pixels) and for the incorporation of various toolbars, scroll bars,
resize handles, and the like. Give the window a name (use no spaces or special characters) if you want it to be the target of links or want to control it with JavaScript. 4 Click OK and verify that the default event is correct.
Apply the Play Sound behavior This behavior has been deprecated as of Dreamweaver CS5.
Apply the Popup Message behavior The Popup Message behavior displays a JavaScript alert with the message you specify. Because JavaScript alerts have only one button (OK), use this behavior to give the user information rather than to present a choice. You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{). Example: The URL for this page is {window.location}, and today is {new Date()}.
Note: The browser controls the appearance of the alert. If you want more control over the appearance, consider using the Open Browser Window behavior. 1 Select an object and choose Popup Message from the Add Behavior menu of the Behaviors panel. 2 Enter your message in the Message box. 3 Click OK and verify that the default event is correct.
Apply the Preload Images behavior The Preload Images behavior shortens display time by caching images that are not shown when the page first appears (for instance, images that will be swapped in with behaviors or scripts). Note: The Swap Image behavior automatically preloads all highlight images when you select the Preload Images option in the Swap Image dialog box, so you do not need to manually add Preload Images when using Swap Image. 1 Select an object and choose Preload Images from the Add Behavior menu of the Behaviors panel. 2 Click Browse to select an image file, or enter the path and filename of an image in the Image Source File box. 3 Click the Plus (+) button at the top of the dialog box to add the image to the Preload Images list. 4 Repeat steps 2 and 3 for all remaining images that you want to preload on the current page. 5 To remove an image from the Preload Images list, select it and click the Minus (–) button.
Last updated 3/28/2012
337
USING DREAMWEAVER Adding JavaScript behaviors
6 Click OK and verify that the default event is correct.
Apply the Set Nav Bar Image behavior This behavior has been deprecated as of Dreamweaver CS5.
Apply the Set Text Of Frame behavior The Set Text Of Frame behavior allows you to dynamically set the text of a frame, replacing the content and formatting of a frame with the content you specify. The content can include any valid HTML code. Use this behavior to display information dynamically. Although the Set Text Of Frame behavior replaces the formatting of a frame, you can select Preserve Background Color to preserve the page background and text color attributes. You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{). Example: The URL for this page is {window.location}, and today is {new Date()}.
1 Select an object and choose Set Text > Set Text Of Frame from the Add Behavior menu of the Behaviors panel. 2 In the Set Text Of Frame dialog box, select the target frame from the Frame menu. 3 Click the Get Current HTML button to copy the current contents of the target frame’s body section. 4 Enter a message in the New HTML box. 5 Click OK and verify that the default event is correct.
More Help topics “Create frames and framesets” on page 185
Apply the Set Text Of Container behavior The Set Text Of Container behavior replaces the content and formatting of an existing container (that is, any element that can contain text or other elements) on a page with the content you specify. The content can include any valid HTML source code. You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{). Example: The URL for this page is {window.location}, and today is {new Date()}.
1 Select an object and select Set Text > Set Text Of Container from the Add Behavior menu of the Behaviors panel. 2 In the Set Text Of Container dialog box, use the Container menu to select the target element. 3 Enter the new text or HTML in the New HTML box. 4 Click OK and verify that the default event is correct.
More Help topics “Insert an AP Div” on page 154
Last updated 3/28/2012
338
USING DREAMWEAVER Adding JavaScript behaviors
Apply the Set Text Of Status Bar behavior The Set Text Of Status Bar behavior shows a message in the status bar at the lower-left corner of the browser window. For example, you can use this behavior to describe the destination of a link in the status bar instead of showing the URL associated with it. Visitors often ignore or overlook messages in the status bar (and not all browsers provide full support for setting the text of the status bar); if your message is important, consider displaying it as a pop-up message or as the text of an AP element. Note: If you use the Set Text Of Status Bar behavior in Dreamweaver, the text of the status bar in the browser is not guaranteed to change because some browsers require special adjustments when changing status bar text. Firefox, for example, requires that you change an Advanced option that lets JavaScript change status bar text. For more information, see your browser’s documentation. You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{). Example: The URL for this page is {window.location}, and today is {new Date()}.
1 Select an object and choose Set Text > Set Text Of Status Bar from the Add Behavior menu of the Behaviors panel. 2 In the Set Text Of Status Bar dialog box, type your message in the Message box.
Keep the message concise. The browser truncates the message if it doesn’t fit in the status bar. 3 Click OK and verify that the default event is correct.
Apply the Set Text Of Text Field behavior The Set Text Of Text Field behavior replaces the content of a form’s text field with the content you specify. You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{). Example: The URL for this page is {window.location}, and today is {new Date()}.
Create a named text field 1 Select Insert > Form > Text Field.
If Dreamweaver prompts you to add a form tag, click Yes. 2 In the Property inspector, type a name for the text field. Make sure the name is unique on the page (don’t use the
same name for multiple elements on the same page, even if they’re in different forms).
Apply Set Text Of Text Field 1 Select a text field and choose Set Text > Set Text Of Field from the Add Behavior menu of the Behaviors panel. 2 Select the target text field from the Text Field menu and enter your new text. 3 Click OK and verify that the default event is correct.
Last updated 3/28/2012
339
USING DREAMWEAVER Adding JavaScript behaviors
Apply the Show-Hide Elements behavior The Show-Hide Elements behavior shows, hides, or restores the default visibility of one or more page elements. This behavior is useful for displaying information as the user interacts with the page. For example, as the user moves the pointer over an image of a plant, you could show a page element giving details about the plant’s growing season and region, how much sun it needs, how large it can grow, and so on. The behavior only shows or hides the pertinent element—it does not actually remove the element from the flow of the page when it is hidden. 1 Select an object and select Show-Hide Elements from the Add Behavior menu of the Behaviors panel.
If Show-Hide Elements is unavailable, you probably have an AP element selected. Because AP elements do not accept events in both 4.0 browsers, you must select a different object—such as the tag or a link () tag. 2 From the Elements list, select the element you want to show or hide and click Show, Hide, or Restore (which
restores the default visibility). 3 Repeat step 2 for all remaining elements whose visibility you want to change. (You can change the visibility of
multiple elements with a single behavior.) 4 Click OK and verify that the default event is correct.
Apply the Show Pop-Up Menu behavior This behavior has been deprecated as of Dreamweaver CS5.
Add, remove, and rearrange pop-up menu items This behavior has been deprecated as of Dreamweaver CS5.
Format a pop-up menu This behavior has been deprecated as of Dreamweaver CS5.
Position a pop-up menu in a document This behavior has been deprecated as of Dreamweaver CS5.
Modify a pop-up menu This behavior has been deprecated as of Dreamweaver CS5.
Apply the Swap Image behavior The Swap Image behavior swaps one image for another by changing the src attribute of the tag. Use this behavior to create button rollovers and other image effects (including swapping more than one image at a time). Inserting a rollover image automatically adds a Swap Image behavior to your page. Note: Because only the src attribute is affected by this behavior, you should swap in an image that has the same dimensions (height and width) as the original. Otherwise, the image you swap in shrinks or expands to fit the dimensions of the original image.
Last updated 3/28/2012
340
USING DREAMWEAVER Adding JavaScript behaviors
There is also a Swap Image Restore behavior, which restores the last set of swapped images to their previous source files. This behavior is automatically added whenever you attach the Swap Image behavior to an object; if you leave the Restore option selected while attaching Swap Image, you should never need to select the Swap Image Restore behavior manually. 1 Select Insert > Image or click the Image button on the Insert panel to insert an image. 2 In the Property inspector, enter a name for the image in the leftmost text box.
It isn’t mandatory to name images; they’re named automatically when you attach the behavior to an object. However, it is easier to distinguish images in the Swap Image dialog box if you name all the images beforehand. 3 Repeat steps 1 and 2 to insert additional images. 4 Select an object (generally the image you’re going to swap) and choose Swap Image from the Add Behavior menu
of the Behaviors panel. 5 From the Images list, select the image whose source you want to change. 6 Click Browse to select the new image file, or enter the path and filename of the new image in the Set Source To box. 7 Repeat steps 5 and 6 for any additional images you want to change. Use the same Swap Image action for all the images
you want to change at once; otherwise, the corresponding Swap Image Restore action won’t restore all of them. 8 Select the Preload Images option to cache the new images when the page is loaded.
This prevents downloading delays when it is time for the images to appear. 9 Click OK and verify that the default event is correct.
Apply the Validate Form behavior The Validate Form behavior checks the contents of specified text fields to ensure that the user has entered the correct type of data. Attach this behavior to individual text fields with the onBlur event to validate the fields as the user is filling out the form, or attach it to the form with the onSubmit event to evaluate several text fields at once when the user clicks the Submit button. Attaching this behavior to a form prevents the submission of forms with invalid data. 1 Select Insert > Form or click the Form button in the Insert panel to insert a form. 2 Select Insert > Form > Text Field or click the Text Field button in the Insert panel to insert a text field.
Repeat this step to insert additional text fields. 3 Choose a validation method:
• To validate individual fields as the user fills out the form, select a text field and select Window > Behaviors. • To validate multiple fields when the user submits the form, click the tag in the tag selector at the lower-left corner of the Document window and choose Window > Behaviors. 4 Select Validate Form from the Add Behavior menu. 5 Do one of the following:
• If you are validating individual fields, select the same field that you selected in the Document window from the Fields list.
• If you are validating multiple fields, select a text field from the Fields list. 6 Select the Required option if the field must contain some data. 7 Select one of the following Accept options: Use Anything Checks that a required field contains data; the data can be of any type.
Last updated 3/28/2012
341
USING DREAMWEAVER Adding JavaScript behaviors
Use E-mail address Checks that the field contains an @ symbol. Use Number Checks that the field contains only numerals. Use Number From Checks that the field contains a number in a specific range.
8 If you have chosen to validate multiple fields, repeat steps 6 and 7 for any additional fields that you want to validate. 9 Click OK.
If you are validating multiple fields when the user submits the form, the onSubmit event automatically appears in the Events menu. 10 If you are validating individual fields, check that the default event is onBlur or onChange. If not, select one of those
events. Both events trigger the Validate Form behavior when the user moves away from the field. The difference is that onBlur occurs whether or not the user has typed in the field, and onChange occurs only if the user changed the contents of the field. The onBlur event is preferred if the field is required.
Last updated 3/28/2012
342
Chapter 13: Working with other applications Cross-application integration About Photoshop, Flash, and Fireworks integration Photoshop, Fireworks, and Flash are powerful web-development tools for creating and managing graphics and SWF files. You can tightly integrate Dreamweaver with these tools to simplify your web design workflow. Note: There is also limited integration with some other applications. For example, you can export an InDesign file as XHTML and continue working on it in Dreamweaver. For a tutorial on this workflow, see www.adobe.com/go/vid0202. You can easily insert images and content created with Adobe Flash (SWF and FLV files) in a Dreamweaver document. You can also edit an image or SWF file in its original editor after you insert it in a Dreamweaver document. Note: To use Dreamweaver in conjunction with these Adobe applications, you must have these applications installed on your computer. For Fireworks and Flash, product integration is achieved through roundtrip editing. Roundtrip editing ensures that code updates are transferred correctly between Dreamweaver and these other applications (for example, to preserve rollover behaviors or links to other files). Dreamweaver also relies on Design Notes for product integration. Design Notes are small files that allow Dreamweaver to locate the source document for an exported image or SWF file. When you export files from Fireworks, Flash, or Photoshop directly to a Dreamweaver defined site, Design Notes containing references to the original PSD, PNG, or Flash authoring file (FLA) are automatically exported to the site along with the web-ready file (GIF, JPEG, PNG, or SWF). In addition to location information, Design Notes contain other pertinent information about exported files. For example, when you export a Fireworks table, Fireworks writes a Design Note for each exported image file in the table. If the exported file contains hotspots or rollovers, the Design Notes include information about the scripts for them. As part of the export operation, Dreamweaver creates a folder named _notes in the same folder as the exported asset. This folder contains the Design Notes that Dreamweaver needs to integrate with Photoshop, Flash, or Fireworks. Note: In order to use Design Notes, you must make sure they are not disabled for your Dreamweaver site. They are enabled by default. However, even if they are disabled, when you insert a Photoshop image file, Dreamweaver creates a Design Note to store the location of the source PSD file. For a tutorial on Dreamweaver and Fireworks integration, see www.adobe.com/go/vid0188. For a tutorial on Dreamweaver and Photoshop integration, see www.adobe.com/go/lrvid4043_dw.
More Help topics “About Design Notes” on page 97 “Enable and disable Design Notes for a site” on page 98 Dreamweaver InDesign tutorial
Last updated 3/28/2012
343
USING DREAMWEAVER Working with other applications
Working with Fireworks and Dreamweaver Insert a Fireworks image Dreamweaver and Fireworks recognize and share many of the same file-editing procedures, including changes to links, image maps, table slices, and more. Together, the two applications provide a streamlined workflow for editing, optimizing, and placing web graphics files in HTML pages. You can place a Fireworks exported graphic directly in a Dreamweaver document using the Insert Image command, or you can create a new Fireworks graphic from a Dreamweaver image placeholder. 1 In the Dreamweaver document, place the insertion point where you want the image to appear, then do one of the
following:
• Select Insert > Image. • In the Common category of the Insert panel, click the Image button or drag it to the document. 2 Navigate to the desired Fireworks exported file, and click OK (Windows) or Open (Macintosh).
Note: If the Fireworks file is not in the current Dreamweaver site, a message appears asking whether you want to copy the file to the root folder. Click Yes.
More Help topics “About Photoshop, Flash, and Fireworks integration” on page 342
Edit a Fireworks image or table from Dreamweaver When you open and edit an image or an image slice that is part of a Fireworks table, Dreamweaver starts Fireworks, which opens the PNG file from which the image or table was exported. Note: This assumes that Fireworks is set as the primary external image editor for PNG files. Fireworks is often also set as the default editor for JPEG and GIF files, although you may wish to set Photoshop as the default editor for these file types. When the image is part of a Fireworks table, you can open the entire Fireworks table for edits, as long as the comment exists in the HTML code. If the source PNG file was exported from Fireworks to a Dreamweaver site using the Dreamweaver Style HTML And Images setting, the Fireworks table comment is automatically inserted in the HTML code. 1 In Dreamweaver, open the Property inspector (Window > Properties) if it isn’t already open. 2 Click the image or image slice to select it.
When you select an image that was exported from Fireworks, the Property inspector identifies the selection as a Fireworks image or table and displays the name of the PNG source file. 3 To start Fireworks for editing, do one of the following:
• In the Property inspector, click Edit. • Hold down Control (Windows) or Command (Macintosh) and double-click the selected image. • Right-click (Windows) or Control-click (Macintosh) the selected image and select Edit With Fireworks from the context menu. Note: If Fireworks cannot locate the source file, you are prompted to locate the PNG source file. When you work with the Fireworks source file, changes are saved to both the source file and the exported file; otherwise, only the exported file is updated.
Last updated 3/28/2012
344
USING DREAMWEAVER Working with other applications
4 In Fireworks, edit the source PNG file and click Done.
Fireworks saves the changes in the PNG file, exports the updated image (or HTML and images), and returns focus to Dreamweaver. In Dreamweaver, the updated image or table appears. For a tutorial about Dreamweaver and Fireworks integration, see www.adobe.com/go/vid0188.
More Help topics “Use an external image editor” on page 232 Dreamweaver Fireworks tutorial
Optimize a Fireworks image from Dreamweaver You can use Dreamweaver to make quick changes to Fireworks images and animations. From within Dreamweaver, you can change optimization settings, animation settings, and the size and area of the exported image. 1 In Dreamweaver, select the desired image and do one of the following:
• Select Command > Optimize Image • Click the Edit Image Settings button in the Property inspector. 2 Make your edits in the Image Preview dialog box:
• To edit optimization settings, click the Options tab. • To edit the size and area of the exported image, click the File tab. 3 When you finish, click OK.
More Help topics “Setting Image Preview dialog box options” on page 353
Use Fireworks to modify Dreamweaver image placeholders You can create a placeholder image in a Dreamweaver document and then start Fireworks to design a graphic image or Fireworks table to replace it. To create a new image from an image placeholder, you must have both Dreamweaver and Fireworks installed on your system. 1 Make sure you’ve already set Fireworks as the image editor for PNG files. 2 In the Document window, click the image placeholder to select it. 3 Start Fireworks in Editing From Dreamweaver mode by doing one of the following:
• In the Property inspector, click Create. • Press Control (Windows) or Command (Macintosh) then double-click the image placeholder. • Right-click (Windows) or Control-click (Macintosh) the image placeholder, then select Create Image In Fireworks. 4 Use Fireworks options to design the image.
Fireworks recognizes the following image placeholder settings you may have set while working with the image placeholder in Dreamweaver: image size (which correlates to Fireworks canvas size), image ID (which Fireworks uses as the default document name for the source file and export file you create), and text alignment. Fireworks also recognizes links and certain behaviors (such as swap image, pop-up menu, and set text) you attached to the image placeholder while working in Dreamweaver.
Last updated 3/28/2012
345
USING DREAMWEAVER Working with other applications
Note: Although Fireworks doesn’t show links you’ve added to an image placeholder, they are preserved. If you draw a hotspot and add a link in Fireworks, it will not delete the link you added to the image placeholder in Dreamweaver; however, if you cut out a slice in Fireworks in the new image, Fireworks will delete the link in the Dreamweaver document when you replace the image placeholder. Fireworks doesn’t recognize the following image placeholder settings: image alignment, color, Vspace and Hspace, and maps. They are disabled in the image placeholder Property inspector. 5 When you finish, click Done to display the save prompt. 6 In the Save In text box, select the folder you defined as your Dreamweaver local site folder.
If you named the image placeholder when you inserted it in the Dreamweaver document, Fireworks populates the File Name box with that name. You can change the name. 7 Click Save to save the PNG file.
The Export dialog box appears. Use this dialog box to export the image as a GIF or JPEG file, or, in the case of sliced images, as HTML and images. 8 For Save In, select the Dreamweaver local site folder.
The Name box automatically displays the name you used for the PNG file. You can change the name. 9 For Save As Type, select the type of file or files you want to export; for example, Images Only or HTML And Images. 10 Click Save to save the exported file.
The file is saved, and focus returns to Dreamweaver. In the Dreamweaver document, the exported file or Fireworks table replaces the image placeholder.
About Fireworks pop-up menus Fireworks lets you quickly and easily create CSS-based pop-up menus. In addition to being extensible and fast to download, the pop-up menus you create with Fireworks give you the following advantages:
• The menu items can be indexed by search engines. • The menu items can be read by screen readers, making your pages more accessible. • The code generated by Fireworks complies to standards and can be validated. You can edit Fireworks pop-up menus with Dreamweaver or with Fireworks, but not both. Changes made in Dreamweaver are not preserved in Fireworks.
Edit Fireworks pop-up menus in Dreamweaver You can create a pop-up menu in Fireworks 8 or later and then edit it with Dreamweaver or with Fireworks (using roundtrip editing), but not with both. If you edit your menus in Dreamweaver and then edit them in Fireworks, you will lose all your previous edits except for the text content. If you prefer to edit your menus with Dreamweaver, you can use Fireworks to create the pop-up menu and then use Dreamweaver exclusively to edit and customize the menu. If you prefer to edit the menus in Fireworks, you can use the roundtrip editing feature in Dreamweaver, but you should not edit the menus directly in Dreamweaver. 1 In Dreamweaver, select the Fireworks table that contains the pop-up menu, and then click Edit in the Property
inspector.
Last updated 3/28/2012
346
USING DREAMWEAVER Working with other applications
The source PNG file opens in Fireworks. 2 In Fireworks, edit the menu with the Pop-up Menu Editor, and then click Done on the Fireworks toolbar.
Fireworks sends the edited pop-up menu back to Dreamweaver. If you created a pop-up menu in Fireworks MX 2004 or earlier, you can edit it in Dreamweaver using the Show Pop-Up Menu dialog box, available from the Behaviors panel.
Edit a pop-up menu created in Fireworks MX 2004 or earlier 1 In Dreamweaver, select the hotspot or image that triggers the pop-up menu. 2 In the Behaviors panel (Shift+F3), double-click Show Pop-Up Menu in the Actions list. 3 Make your changes in the Pop-Up Menu dialog box and click OK.
More Help topics “Apply the Show Pop-Up Menu behavior” on page 339
Specify launch-and-edit preferences for Fireworks source files When you use Fireworks to edit images, the images in your web pages are normally exported by Fireworks from a source PNG file. When you open an image file in Dreamweaver to edit it, Fireworks automatically opens the source PNG file, prompting you to locate the PNG file if it cannot be found. If you prefer, you can set preferences in Fireworks to have Dreamweaver open the inserted image, or you can have Fireworks give you the option of using the inserted image file or the Fireworks source file every time you open an image in Dreamweaver. Note: Dreamweaver recognizes the Fireworks launch-and-edit preferences only in certain cases. Specifically, you must be opening and optimizing an image that is not part of a Fireworks table and contains a correct Design Notes path to a source PNG file. 1 In Fireworks, select Edit > Preferences (Windows) or Fireworks > Preferences (Macintosh) and then click the
Launch And Edit tab (Windows) or select Launch And Edit from the pop-up menu (Macintosh). 2 Specify the preference options to use when editing or optimizing Fireworks images placed in an external
application: Always Use Source PNG Automatically opens the Fireworks PNG file that is defined in the Design Note as the source of the placed image. Updates are made to the source PNG file and its corresponding placed image. Never Use Source PNG Automatically opens the placed Fireworks image, whether or not a source PNG file exists.
Updates are made to the placed image only. Ask When Launching Displays a message asking whether to open the source PNG file. You can also specify global
launch-and-edit preferences from this message.
Insert Fireworks HTML code in a Dreamweaver document From Fireworks, you can use the Export command to export and save optimized images and HTML files to a location inside a Dreamweaver site folder. You can then insert the file in Dreamweaver. Dreamweaver lets you insert Fireworksgenerated HTML code, complete with associated images, slices, and JavaScript, into a document. 1 In Dreamweaver document, place the insertion point where you want to insert the Fireworks HTML code. 2 Do one of the following:
• Select Insert > Image Objects > Fireworks HTML.
Last updated 3/28/2012
347
USING DREAMWEAVER Working with other applications
• In the Common category of the Insert panel, click the Images button and choose Insert Fireworks HTML from the popup menu. 3 Click Browse to select a Fireworks HTML file. 4 If you will have no further use for the file, select Delete File After Insertion. Selecting this option has no effect on
the source PNG file associated with the HTML file. Note: If the HTML file is on a network drive, it is permanently deleted—not moved to the Recycle Bin or Trash. 5 Click OK to insert the HTML code, along with its associated images, slices, and JavaScript, into the Dreamweaver
document.
Paste Fireworks HTML code into Dreamweaver A fast way to place Fireworks-generated images and tables in Dreamweaver is to copy and paste Fireworks HTML code directly into a Dreamweaver document.
Copy and paste Fireworks HTML code into Dreamweaver 1 In Fireworks, select Edit > Copy HTML Code. 2 Follow the wizard as it guides you through the settings for exporting your HTML and images. When prompted,
specify your Dreamweaver site folder as the destination for the exported images. The wizard exports the images to the specified destination and copies the HTML code to the Clipboard. 3 In Dreamweaver document, place the insertion point where you want to paste the HTML code, and select Edit >
Paste Fireworks HTML. All HTML and JavaScript code associated with the Fireworks files you exported is copied into the Dreamweaver document, and all links to images are updated.
Export and paste Fireworks HTML code into Dreamweaver 1 In Fireworks, select File > Export. 2 Specify your Dreamweaver site folder as the destination for the exported images. 3 In the Export pop-up menu, select HTML And Images. 4 In the HTML pop-up menu, select Copy To Clipboard, and then click Export. 5 In the Dreamweaver document, place the insertion point where you want to paste the exported HTML code, and
select Edit > Paste Fireworks HTML. All HTML and JavaScript code associated with the Fireworks files you exported is copied into the Dreamweaver document, and all links to images are updated.
Update Fireworks HTML code placed in Dreamweaver In Fireworks, the File > Update HTML command provides an alternative to the launch-and-edit technique for updating Fireworks files placed in Dreamweaver. With Update HTML, you can edit a source PNG image in Fireworks and then automatically update any exported HTML code and image files placed in a Dreamweaver document. This command lets you update Dreamweaver files even when Dreamweaver is not running. 1 In Fireworks, open the source PNG file and make your edits. 2 Select File > Save. 3 In Fireworks, select File > Update HTML.
Last updated 3/28/2012
348
USING DREAMWEAVER Working with other applications
4 Navigate to the Dreamweaver file containing the HTML you want to update, and click Open. 5 Navigate to the folder destination where you want to place the updated image files, and click Select (Windows) or
Choose (Macintosh). Fireworks updates the HTML and JavaScript code in the Dreamweaver document. Fireworks also exports updated images associated with the HTML and places the images in the specified destination folder. If Fireworks cannot find matching HTML code to update, it gives you the option of inserting new HTML code into the Dreamweaver document. Fireworks places the JavaScript section of the new code at the beginning of the document and places the HTML table or link to the image at the end.
Create a web photo album The Create Web Photo Album feature has been deprecated as of Dreamweaver CS5.
Working with Photoshop and Dreamweaver About Photoshop integration You can insert Photoshop image files (PSD format) into web pages in Dreamweaver and let Dreamweaver optimize them as web-ready images (GIF, JPEG, and PNG formats). When you do this, Dreamweaver inserts the image as a Smart Object and maintains a live connection to the original PSD file. You can also paste all or part of a multi-layered or multi-sliced Photoshop image into a web page in Dreamweaver. When you copy and paste from Photoshop, however, no live connection to the original file is maintained. To update the image, make your changes in Photoshop, and copy and paste again. Note: If you use this integration feature often, you may want to store your Photoshop files in your Dreamweaver site for easier access. If you do, be sure to cloak them to avoid exposure of the original assets, as well as unnecessary transfers between the local site and the remote server. For a tutorial about the Smart Object workflow in Photoshop and Dreamweaver, see www.adobe.com/go/lrvid4043_dw.
About Smart Objects and Photoshop-Dreamweaver workflows There are two main workflows for working with Photoshop files in Dreamweaver: the copy/paste workflow, and the Smart Objects workflow. Copy/paste workflow The copy/paste workflow lets you select slices or layers in a Photoshop file, and then use Dreamweaver to insert them as web-ready images. If you want to update the content later on, however, you must open the original Photoshop file, make your changes, copy your slice or layer to the clipboard again, and then paste the updated slice or layer into Dreamweaver. This workflow is only recommended when you want to insert part of a Photoshop file (for example, a section of a design comp) as an image on a web page. Smart Objects workflow When working with complete Photoshop files, Adobe recommends the Smart Objects workflow. A Smart Object in Dreamweaver is an image asset placed on a web page that has a live connection to an original Photoshop (PSD) file. In Dreamweaver Design view, a Smart Object is denoted by an icon in the upper left corner of the image.
Last updated 3/28/2012
349
USING DREAMWEAVER Working with other applications
Smart Object
When the web image (that is, the image on the Dreamweaver page) is out of sync with the original Photoshop file, Dreamweaver detects that the original file has been updated, and displays one of the Smart Object icon’s arrows in red. When you select the web image in Design view and click the Update from Original button in the Property inspector, the image updates automatically, reflecting any changes that you made to the original Photoshop file. When you use the Smart Objects workflow, you do not need to open Photoshop to update a web image. Additionally, any updates you make to a Smart Object in Dreamweaver are non-destructive. That is, you can change the web version of the image on your page while keeping the original Photoshop image intact. You can also update a Smart Object without selecting the web image in Design view. The Assets panel lets you update all Smart Objects, including images that might not be selectable in the Document window (for example, CSS background images). Image optimization settings For both the copy/paste and the Smart Object workflows, you can specify optimization settings in the Image Preview dialog box. This dialog box lets you set things like file format, image quality, and so on. If you are copying a slice or a layer for the first time, or inserting a Photoshop file as a Smart Object for the first time, Dreamweaver displays this dialog so that you can easily create the web image. If you copy and paste an update to a particular slice or layer, Dreameaver remembers the original settings and recreates the web image with those settings. Likewise, when you update a Smart Object using the Property inspector, Dreamweaver uses the same settings you used when you first inserted the image. You can change an image’s settings at any time by selecting the web image in Design view, and then clicking the Edit Image Settingsbutton in the Property inspector.
Last updated 3/28/2012
350
USING DREAMWEAVER Working with other applications
Storing Photoshop files If you’ve inserted a web image, and have not stored the original Photoshop file in your Dreamweaver site, Dreamweaver recognizes the path to the original file as an absolute local file path. (This is true for both the copy/paste and Smart Object workflows.) For example, if the path to your Dreamweaver site is C:\Sites\mySite, and your Photoshop file is stored in C:\Images\Photoshop, Dreameaver will not recognize the original asset as part of the site called mySite. This will cause problems if you ever want to share the Photoshop file with other team members because Dreamweaver will only recognize the file as being available on a particular local hard drive. If you store the Photoshop file inside your site, however, Dreamweaver establishes a site-relative path to the file. Any user with access to the site will also be able to establish the correct path to the file, assuming that you have also provided the original file for them to download. For a video tutorial on the Smart Objects workflow in Photoshop and Dreamweaver, see www.adobe.com/go/lrvid4043_dw.
Create a Smart Object When you insert a Photoshop image (PSD file) into your page, Dreamweaver creates a Smart Object. A Smart Object is a web-ready image that maintains a live connection to the original Photoshop image. Whenever you update the original image in Photoshop, Dreamweaver gives you the option of updating the image in Dreamweaver with the click of a button. 1 In Dreamweaver (Design or Code view), place the insertion point on your page where you want the image inserted. 2 Select Insert > Image.
You can also drag the PSD file to the page from the Files panel if you’re storing your Photoshop files in your website. If you do so, you’ll skip the next step. 3 Locate your Photoshop PSD image file in the Select Image Source dialog box by clicking the Browse button and
navigating to it. 4 In the Image Preview dialog box that appears, adjust optimization settings as needed and click OK. 5 Save the web-ready image file to a location within your website’s root folder.
Dreamweaver creates the Smart Object based on the selected optimization settings and places a web-ready version of the image on your page. The Smart Object maintains a live connection to the original image and lets you know when the two are out of synch. Note: If you decide later that you want to change the optimization settings for an image placed in your pages, you can select the image, click the Edit Image Settings button in the Property inspector, and make changes in the Image Preview dialog box. Changes made in the Image Preview dialog box are applied non-destructively. Dreamweaver never modifies the original Photoshop file, and always re-creates the web image based on the original data. For a video tutorial about working with Photoshop Smart Objects, see www.adobe.com/go/lrvid4043_dw.
Update a Smart Object If you change the Photoshop file to which your Smart Object is linked, Dreamweaver notifies you that the web-ready image is out of sync with the original. In Dreamweaver, Smart Objects are denoted by an icon at the upper left corner of the image. When the web-ready image in Dreamweaver is in sync with the original Photoshop file, both of the arrows in the icon are green. When the web-ready image is out of sync with the original Photoshop file, one of the icon’s arrows turns read. ❖ To update a Smart Object with the current contents of the original Photoshop file, select the Smart Object in the
Document window, and then click the Update from Original button in the Property inspector.
Last updated 3/28/2012
351
USING DREAMWEAVER Working with other applications
Note: You do not need Photoshop installed to make the update from Dreamweaver.
Update multiple Smart Objects You can update multiple Smart Objects at once using the Assets panel. The Assets panel also lets you see Smart Objects that might not be selectable in the Document window (for example, CSS background images). 1 In the Files panel, click the Assets tab to view site assets. 2 Make sure that Images view is selected. If it isn’t, click the Images button. 3 Select each image asset in the Assets panel. When you select a Smart Object, you’ll see the Smart Object icon in the
upper left corner of the image. Regular images do not have this icon. 4 For each Smart Object that you want to update, right-click the filename and select Update from Original. You can
also Control-click to select multiple filenames and update them all at once. Note: You do not need Photoshop installed to make the update from Dreamweaver.
Resize a Smart Object You can resize a Smart Object in the Document window just as you would any other image. 1 Select the Smart Object in the Document window and drag the resize handles to resize the image. You can maintain
the width and height proportions by holding down the Shift key as you drag. 2 Click the Update from Original button in the Property inspector.
When you update the Smart Object, the web image non-destructively re-renders at the new size, based on the current contents of the original file, and the original optimization settings.
Edit a Smart Object’s original Photoshop file After you create a Smart Object on your Dreamweaver page, you can edit the original PSD file in Photoshop. After you make your changes in Photoshop, you can then easily update the web image in Dreamweaver. Note: Make sure that you have Photoshop set as your primary external image editor. 1 Select the Smart Object in the Document window. 2 Click the Edit button in the Property inspector. 3 Make your changes in Photoshop and save the new PSD file. 4 In Dreamweaver, select the Smart Object again and click the Update from Original button.
Note: If you changed the size of your image in Photoshop, you need to reset the size of the web image in Dreamweaver. Dreamweaver updates a Smart Object based only on the contents of the original Photoshop file, and not its size. To sync the size of a web image with the size of the original Photoshop file, right-click the image and select Reset Size To Original.
Smart Object states The following table lists the various states for Smart Objects.
Last updated 3/28/2012
352
USING DREAMWEAVER Working with other applications
SmartObject state
Description
Recommended action
Images synched
The web image is in sync with the current contents of the original None Photoshop file. Width and height attributes in the HTML code match the dimensions of the web image.
Original asset modified
The original Photoshop file has been modified after the creation Use the Update From Original button in the of the web image in Dreamweaver. Property inspector to sync the two images.
Dimensions of web image are different from selected HTML width and height
The width and height attributes in the HTML code are different from the width and height dimensions of the web image that Dreamweaver created upon insertion. If the web image’s dimensions are smaller than the selected HTML width and height values, the web image can appear pixelated.
Use the Update From Original button in the Property inspector to re-create the web image from the original Photoshop file. Dreamweaver uses the currently specified HTML width and height dimensions when it re-creates the image.
Dimensions of original asset The width and height attributes in the HTML code are larger than Don’t create web images with dimensions are too small for selected the width and height dimensions of the original Photoshop file. larger than the dimensions of the original HTML width and height The web image can appear pixelated. Photoshop file. Original asset not found
Dreamweaver cannot find the original Photoshop file specified in the Original text box of the Property inspector.
Correct the file path in the Original text box of the Property inspector, or move the Photoshop file to the location that’s currently specified.
Copy and paste a selection from Photoshop You can copy all or some of a Photoshop image and paste the selection into your Dreamweaver page as a web-ready image. You can copy a single layer or a set of layers for a selected area of the image or you can copy a slice of the image. When you do this, however, Dreamweaver does not create a Smart Object. Note: While the Update from Original functionality is not available for pasted images, you can still open and edit the original Photoshop file by selecting the pasted image and clicking the Edit button in the Property inspector. 1 In Photoshop, do one of the following:
• Copy all or part of a single layer by using the Marquee tool to select the portion you want to copy, and then choose Edit > Copy. This copies only the active layer for the selected area into the clipboard. If you have layer-based effects, they are not copied.
• Copy and merge multiple layers by using the Marquee tool to select the portion you want to copy, and then choose Edit > Copy Merged. This flattens and copies all the selected area’s active and lower layers into the clipboard. If you have layer-based effects associated with any of these layers, they are copied.
• Copy a slice by using the Slice Select tool to select the slice, and then choose Edit > Copy. This flattens and copies all the slice’s active and lower layers into the clipboard. You can choose Select > All to quickly select all of an image for copying. 2 In Dreamweaver (Design or Code view), place the insertion point on your page where you want the image inserted. 3 Select Edit > Paste. 4 In the Image Preview dialog box, adjust optimization settings as needed and click OK. 5 Save the web-ready image file to a location within your website’s root folder.
Dreamweaver defines the image according to your optimization settings and places a web-ready version of your image in your page. Information about the image, such as the location of the original PSD source file, is saved in a Design Note, regardless of whether you have enabled Design Notes for your site. The Design Note allows you to return to edit the original Photoshop file from Dreamweaver.
Last updated 3/28/2012
353
USING DREAMWEAVER Working with other applications
For a tutorial on copying and pasting between different applications, including Dreamweaver and Photoshop, see www.adobe.com/go/vid0193.
Edit pasted images After you paste Photoshop images in your Dreamweaver pages, you can edit the original PSD file in Photoshop. When using the copy/paste workflow, Adobe recommends that you always make your edits to the original PSD file (rather than the web-ready image itself), and then repaste to maintain single sourcing. Note: Make sure that you have Photoshop set as your primary external image editor for the file type you want to edit. 1 In Dreamweaver, select a web-ready image that was originally created in Photoshop and do one of the following:
• Click the Edit button in the image’s Property inspector. • Press Control (Windows) or Command (Macintosh) as you double-click the file. • Right-click (Windows) or Control-click (Macintosh) an image, choose Edit Original With from the context menu, and then choose Photoshop. Note: This assumes that Photoshop is set as the primary external image editor for PSD image files. You may also want to set Photoshop as the default editor for JPEG, GIF, and PNG file types. 2 Edit the file in Photoshop. 3 Return to Dreamweaver and paste the updated image or selection into your page.
If you want to reoptimize the image at any time, you can select the image and click the Edit Image Settings button in the Property inspector.
Setting Image Preview dialog box options Image Preview dialog box options When you create a Smart Object or paste a selection from Photoshop, Dreamweaver displays the Image Preview dialog box. (Dreamweaver also displays this dialog box for any other kind of image if you select the image and click the Edit Image Settings button in the Property inspector.) This dialog box lets you define and preview settings for web-ready images using the right mix of color, compression, and quality. A web-ready image is one that can be displayed by all modern web browsers and looks the same no matter what system or browser the viewer is using. When you insert a Photoshop image, the Image Preview dialog box lets you adjust various settings for optimal web publication. In general, the settings result in a trade-off between quality and file size.
Last updated 3/28/2012
354
USING DREAMWEAVER Working with other applications
A
B
C
The Image Preview dialog box A. Options tab B. File tab C. Preview panel
Note: Whatever settings you select only affect the exported version of the image file. The original Photoshop PSD or Fireworks PNG file always remains untouched. The Image Preview dialog box has three sections:
• The Options tab lets you define which file format to use and set preferences such as color. • The File tab lets you set the scale factor and target file size of the image. • The Preview panel lets you see a version of the image with your current settings. Many image options are available in the Options tab and they vary depending on the file format you choose. Several sets of GIF and JPEG image options are available for your convenience in the Saved Settings pop-up menu. JPEG image options You can optimize a JPEG image by setting its compression and smoothing options. You cannot edit its color palette. Quality Use the slider to increase or decrease the quality of the image. Better quality results in a larger file. Smoothing Allows you to increase the smoothing as needed. Lower quality images may require a higher value. Progressive Browser Display Displays an image initially at low resolution and progressively increases the resolution
during download. Not selected by default. Sharpen Color Edges Allows you to get a higher quality image.
Last updated 3/28/2012
355
USING DREAMWEAVER Working with other applications
Matte Allows you to set the background of the image. You can maintain the transparency of a 32-bpc (bits per channel) PNG by clicking the transparency icon in the Matte dialog box. You can also use Matte to anti-alias softedged objects that lie directly above the canvas by matching the matte color to the target background. Remove Unused Colors Reduces file size by removing colors not used in the image. Optimize to Size Specifies the image size, in kilobytes. For 8-bpc images, the wizard attempts to achieve the requested
file size by adjusting the number of colors or dithering. GIF and PNG image options In the Options tab, you can set a transparency value for individual colors in GIF and 8-bpc PNG images so that the background of the web page is visible through areas with those colors. Do this by adjusting the color palette on the left of the Options tab. PNG images that have 32-bpc format automatically contain transparency, though you won’t see a transparency option for 32-bpc PNGs in the Optimize panel. Palette Set to Adaptive by default. Select one of the saved color palette settings from the pop-up menu if you want to use a preset set of options Loss Set to 0 by default. Not applicable to PNG images. Dither Approximates colors not in the current palette by alternating similar-colored pixels so that they appear to blend
to the missing color. Dithering is especially helpful when exporting images with complex blends or gradients, or when exporting photographic images to an 8-bpc graphic format such as GIF. Not selected by default. Note: Dithering can greatly increase file size. Number Of Colors List Set to 256 by default. The number of colors is dependent on the current behavior of the palette.
For example, the "Web 216" palette only displays 216 colors. Color palette The display of colors varies depending on the selected palette behavior and maximum number of colors. Palette Tools Click any pixel in the palette and then click these icons to change, add, or delete color, or to make a color transparent, web safe, or locked. Select Transparency Color Icons These buttons allow you to select, add, or remove a palette color. For example, if you choose the Select Transparency Color option, you can click any pixel in the palette or on a point of color in the preview panel to render it transparent. Transparency Pop-Up Menu Allows you to set index, alpha, or no transparency. A gray-and-white checkerboard on
document previews denotes transparent areas. To see how your choices affect the image, choose 2-up or 4-up in the image preview and click an image other than the original.
• Index Use index transparency when exporting GIF images that contain transparent areas. With index transparency, you set specific colors to be transparent upon export. Index transparency turns on or turns off pixels with specific color values. • Alpha Use alpha transparency when exporting 8-bpc PNG images that contain transparent areas. Alpha transparency allows gradient transparency and semi-opaque pixels. Matte Lets you set the background of the image. You can maintain the transparency of a 32-bpc PNG by clicking the transparency icon in the Matte dialog box. You can also use Matte to anti-alias soft-edged objects that lie directly above the canvas by matching the matte color to the target background. Remove Unused Colors Reduces file size by removing colors not used in the image. Interlaced Browser Display Displays an interlaced image initially at low resolution and progressively increases to full resolution during download. Not selected by default.
Last updated 3/28/2012
356
USING DREAMWEAVER Working with other applications
Optimize To Size Lets you specify a size, in kilobytes, for the image. For 8-bpc images, the wizard attempts to achieve
the requested file size by adjusting the number of colors or dithering. Saved settings Dreamweaver provides several option settings for your convenience. Depending on the saved settings you choose, the file-type-specific image options described above may change. GIF Web 216 Forces all colors to web-safe colors. The color palette contains up to 216 colors. GIF Websnap 256 Converts web-unsafe colors to their closest web-safe color. The color palette contains up to a maximum of 256 colors. GIF Websnap 128 Converts web-unsafe colors to their closest web-safe color. The color palette contains up to 128
colors. GIF Adaptive 256 A color palette that contains only the actual colors used in the graphic. The color palette contains
up to a maximum of 256 colors. JPEG - Better Quality Sets quality to 80 and smoothing to 0, resulting in a high-quality but larger graphic. JPEG - Smaller File Sets quality to 60 and smoothing to 2, resulting in a graphic less than half the size of a Better Quality
JPEG but with reduced quality.
(Optional) Change the image’s scale or export area options on the File tab 1 Select the File tab. 2 Shrink or expand the image in one of the following ways:
• Specify a scale percentage. • Enter absolute pixel values for width or height. 3 Select Constrain to maintain the image’s original proportions as you rescale it. 4 Change the shape of the placed image by choosing the Export Area option and doing one of the following:
• Drag the dotted border around the previewed image as needed. You can drag the image within the borders to move hidden areas into view.
• Enter pixel coordinates for the image’s boundaries.
(Optional) Preview and adjust images in the Preview panel 1 In the Image Preview dialog box, select the Preview option if you want to see what the image looks like with your
settings. If performance is an issue, you may want to deselect this option. 2
Select one of the saved color palette settings from the Saved Settings pop-up menu if you want to use a preset set of options.
3 If your image is larger than the preview area, use the pointer tool to grab the previewed image and pan it to see
different parts. 4 Use the crop tool to reduce the image’s size. You may need to first zoom out to see the entire image. 5 Choose a value from the Zoom pop-up menu to expand or reduce your view of the previewed image. You can also
choose the Zoom tool and click to zoom in; Alt-click (Windows) or Option-click (Macintosh) to zoom out. 6 You can preview two or four different optimizations by clicking the 2-up or 4-up button at the bottom of the
preview panel and choosing different color palettes for each pane. Note: The animation controls in the Image Preview dialog box are always disabled for Photoshop images.
Last updated 3/28/2012
357
USING DREAMWEAVER Working with other applications
Working with Flash and Dreamweaver Edit a SWF file from Dreamweaver in Flash If you have both Flash and Dreamweaver installed, you can select a SWF file in a Dreamweaver document and use Flash to edit it. Flash does not edit the SWF file directly; it edits the source document (FLA file) and re-exports the SWF file. 1 In Dreamweaver, open the Property inspector (Window > Properties). 2 In the Dreamweaver document, do one of the following:
• Click the SWF file placeholder to select it; then in the Property inspector click Edit. • Right-click (Windows) or Control-click (Macintosh) the placeholder for the SWF file, and select Edit With Flash from the context menu. Dreamweaver switches the focus to Flash, and Flash attempts to locate the Flash authoring file (FLA) for the selected SWF file. If Flash cannot locate the Flash authoring file, you are prompted to locate it. Note: If the FLA file or SWF file is locked, check out the file in Dreamweaver. 3 In Flash, edit the FLA file. The Flash Document window indicates that you are modifying the file from within
Dreamweaver. 4 When you finish making edits, click Done.
Flash updates the FLA file, re-exports it as a SWF file, closes, and then returns the focus to the Dreamweaver document. Note: To update the SWF file and keep Flash open, in Flash select File > Update for Dreamweaver. 5 To view the updated file in the document, click Play in the Dreamweaver Property inspector or press F12 to preview
your page in a browser window.
Working with Adobe Bridge and Dreamweaver About Adobe Bridge Dreamweaver provides seamless integration with Adobe Bridge, the cross-platform file browser included with Adobe Creative Suite 5 components. Adobe Bridge helps you locate, organize, and browse the assets you need to create print, web, video, and mobile content. You can start Adobe Bridge from any Creative Suitecomponent (except Acrobat 9), and use it to access both Adobe and non-Adobe asset types. From Adobe Bridge, you can:
• Preview, search, sort, and process files without opening individual Creative Suite applications. You can also edit metadata for files and use Adobe Bridge to place files into your documents, projects, or compositions.
• Import and edit photos from a digital camera card, group related photos into stacks, and open and edit Camera Raw files without starting Photoshop.
• Perform automated tasks, such as batch commands. •
Synchronize color settings across color-managed Creative Suite components.
More Help topics Creative Suite 5 - Bridge
Last updated 3/28/2012
358
USING DREAMWEAVER Working with other applications
Start Adobe Bridge from Dreamweaver You can start Adobe Bridge from Dreamweaver to view your files before placing them or dragging them in your page layout. ❖ You can start Adobe Bridge in several different ways:
• Select File > Browse In Bridge. • Click the Browse In Bridge button in the Standard toolbar. • Press the Browse In Bridge shortcut from the keyboard: Control+Alt+O (Windows) or Command+Option+O (Macintosh). Adobe Bridge opens in File Browser mode, showing the contents of the last-opened folder in Dreamweaver. If Adobe Bridge was already open, it becomes the active window. Note: Adobe Bridge is only installed with Dreamweaver CS5 when you install Creative Suite CS5; it is not included with the standalone version of Dreamweaver CS5. However, Adobe Bridge was included if you previously installed Dreamweaver CS3 or CS4, so if you still have Adobe Bridge installed from those versions, Dreamweaver CS5 can access it and use it.
Placing files into Dreamweaver from Adobe Bridge You can insert files into Dreamweaver pages by inserting them or by dragging them from Adobe Bridge into your page. The Dreamweaver document in which you want to insert the file must be open and in Design view to use this feature. You can insert most file types into your pages, but Dreamweaver handles them differently:
• If you insert a web-ready image (JPEG, GIF, or PNG), Dreamweaver inserts the image files directly into your page and places a copy in your website’s default images folder.
• If you insert a Photoshop PSD file, you need to define its optimization settings before Dreamweaver can place it in your page.
• If you insert a non-image file, such as mp3, PDF, or a file with an unknown file type, Dreamweaver inserts a link to the source file.
• If you insert an HTML file, Dreamweaver inserts a link to the source file. • (Windows only) If you have Microsoft Office installed and you are inserting a Microsoft Word or Excel file, you must specify if you want to insert the file itself or insert a link to the source file. If you want to insert the file, you can specify how much of the file’s formatting you want to keep.
More Help topics “Create a Smart Object” on page 350 “Working with Photoshop and Dreamweaver” on page 348
Place an Adobe Bridge file in your page 1 In Dreamweaver (Design view), place the insertion point on your page where you want the file inserted. 2 In Adobe Bridge, select the file and choose File > Place In Dreamweaver. 3 If the file is not in your site’s root folder, you are prompted to copy it there. 4 If you have set Edit > Preferences > Accessibility to show attributes when inserting images, the Image Tag
Accessibility Attributes dialog box is displayed when you insert web-ready images such as JPEG and GIF.
Last updated 3/28/2012
359
USING DREAMWEAVER Working with other applications
Note: If your insertion point is in Code view, Adobe Bridge starts as usual but cannot place the file. You can only place files in Design view.
Drag a file from Bridge into your page 1 In Dreamweaver (Design view), place the insertion point on your page where you want the image inserted. 2 Start Adobe Bridge if it isn't already open. 3 In Adobe Bridge, select one or more files and drag them into your Dreamweaver page. 4 If a file is not in your site’s root folder, you are prompted to copy it there. 5 If you have set Edit > Preferences > Accessibility to show attributes when inserting images, the Image Tag
Accessibility Attributes dialog box is displayed when you insert web-safe images such as JPEG and GIF. Note: If your insertion point is in Code view, Adobe Bridge starts as usual but cannot place the file. You can only place files in Design view.
Start Dreamweaver from Adobe Bridge ❖ Select a file in Adobe Bridge and do one of the following:
• Select File > Open With > Adobe Dreamweaver. • Right-click (Control-click on Macintosh) and then choose Open With > Adobe Dreamweaver from the context menu. Note: If Dreamweaver is already open, this action makes the program active. If Dreamweaver is not open, Adobe Bridge starts it, bypassing the Welcome Screen.
Working with Device Central and Dreamweaver Using Adobe Device Central with Dreamweaver Device Central enables Dreamweaver web designers and developers to preview how Dreamweaver files will look on a wide variety of mobile devices. Device Central uses Opera’s Small-Screen Rendering™ to give designers and developers an impression of how their web page looks on a small screen. It also enables designers and developers to test if their CSS behaves correctly. For example, a web developer may have a customer who wants to make a website available on mobile phones. The web developer can use Dreamweaver to create preliminary pages and use Device Central to test how those pages look on different devices.
More Help topics Adobe Device Central Help
Preview mobile content with Adobe Device Central and Dreamweaver To preview pages created in Dreamweaver on various mobile devices, use Device Central with its built-in Opera Small-Screen Rendering feature. Different devices have different browsers installed, but the preview can give a good impression of how content will look and behave on a selected device. 1 Start Dreamweaver. 2 Open a file.
Last updated 3/28/2012
360
USING DREAMWEAVER Working with other applications
3 Do one of the following:
• Select File > Preview in Browser > Device Central. • On the document window toolbar, click and hold the Preview/Debug In browser button
and select Preview In
Device Central. The file is displayed in the Device Central Emulator tab. To continue testing, double-click the name of a different device in the Device Sets or Available Devices lists.
Tips for creating Dreamweaver web content for mobile devices Device Central previews web pages created in Dreamweaver using Opera’s Small-Screen Rendering. This preview can give you a good idea of what a web page looks like on a mobile device. Note: Opera’s Small-Screen Rendering may or may not be pre-installed on any individual emulated device. Device Central simply gives a preview of how the content would look if Opera’s Small-Screen Rendering was installed. Use the tips below to ensure that web pages created in Dreamweaver display well on mobile devices.
• If you use the Adobe® Spry framework to develop content, add the following line of HTML to your pages so they can render CSS and execute JavaScript™ correctly in Device Central:
• Opera’s Small-Screen Rendering does not support frames, pop-ups, underlining, strikethrough, overlining, blink, and marquee. Try to avoid these design elements.
• Keep web pages for mobile devices simple. In particular, use a minimum number of fonts, font sizes, and colors. • Scaling down image sizes and reducing the number of colors required increase the chances that the images will appear as intended. Use CSS or HTML to specify an exact height and width for each image used. Provide alt text for all images. Note: The Opera software website is a good source of information about optimizing web pages for mobile devices. For more tips and techniques for creating content for mobile phones and devices, see www.adobe.com/go/learn_cs_mobilewiki_en.
Working with ConnectNow and Dreamweaver Working with ConnectNow Adobe® ConnectNow provides you with a secure, personal online meeting room where you can meet and collaborate with others via the web in real time. With ConnectNow, you can share and annotate your computer screen, send chat messages, and communicate using integrated audio. You can also broadcast live video, share files, capture meeting notes, and control an attendee's computer. You can access ConnectNow directly from the application interface. 1 Choose File > Share My Screen. 2 In the Sign In to Adobe CS Live dialog box, enter your email address and password, and click Sign In. If you don’t
have an Adobe ID, click the Create Adobe ID button. 3 To share your screen, click the Share My Computer Screen button at the center of the ConnectNow application
window.
Last updated 3/28/2012
361
USING DREAMWEAVER Working with other applications
For complete instructions on using ConnectNow, see Adobe ConnectNow Help. For a video tutorial about using ConnectNow, see Using ConnectNow to share your screen (7:12). (This demonstration is in Dreamweaver.)
AIR Extension for Dreamweaver The Adobe® AIR® Extension for Dreamweaver® lets you transform a web-based application into a desktop application. Users can then run the application on their desktops and, in some cases, without an Internet connection. You can use the extension with Dreamweaver CS3 and later. It is not compatible with Dreamweaver 8. Note: Adobe AIR does not support Adobe InContext Editing. If you use the AIR Extension for Dreamweaver to export an application that contains InContext Editing regions, the InContext Editing functionality will not work.
Installing the AIR Extension for Dreamweaver The AIR Extension for Dreamweaver helps you to create rich Internet applications for the desktop. For example, you might have a set of web pages that interact with each other to display XML data. You can use the Adobe AIR Extension for Dreamweaver to package this set of pages into a small application that can be installed on a user’s computer. When the user runs the application from their desktop, the application loads and displays the website in its own application window, independent of a browser. The user can then browse the website locally on their computer without an Internet connection. Dynamic pages such as Adobe® ColdFusion® and PHP pages won’t run in Adobe AIR. The runtime only works with HTML and JavaScript. However, you can use JavaScript in your pages to call any web service exposed on the Internet— including ColdFusion- or PHP-generated services—with Ajax methods such as XMLHTTPRequest or Adobe AIRspecific APIs.
System requirements To use the Adobe AIR Extension for Dreamweaver, the following software must be installed and properly configured:
• Dreamweaver CS3 or later • Adobe® Extension Manager CS3 or later • Java JRE 1.4 or later (necessary for creating the Adobe AIRfile). The Java JRE is available at http://java.sun.com/. The preceding requirements are only for creating and previewing Adobe AIR applications in Dreamweaver. To install and run an Adobe AIRapplication on the desktop, you must also install Adobe AIR on your computer. To download the runtime, see www.adobe.com/go/air.
Install the Adobe AIR Extension for Dreamweaver 1 Download the Adobe AIR Extension for Dreamweaver here: http://www.adobe.com/products/air/tools/ajax/. 2 Double-click the .mxp extension file in Windows Explorer(Windows) or in the Finder (Macintosh). 3 Follow the onscreen instructions to install the extension. 4 After you’re finished, restart Dreamweaver.
For information about using the Adobe AIR Extension for Dreamweaver, see Using the AIR Extension for Dreamweaver.
Last updated 3/28/2012
362
USING DREAMWEAVER Working with other applications
Creating an AIR application in Dreamweaver To create an HTML-based AIR application in Dreamweaver, you select an existing site to package as an AIR application. 1 Make sure that the web pages you want to package into an application are contained in a defined Dreamweaver site. 2 In Dreamweaver, open the home page of the set of pages you want to package. 3 Select Site > Air Application Settings. 4 Complete the AIR Application and Installer Settings dialog box, and then click Create AIR File.
For more information, see the dialog box options listed below. The first time you create an Adobe AIR file, Dreamweaver creates an application.xml file in your site root folder. This file serves as a manifest, defining various properties of the application. The following describes the options in the AIR Application and Installer Settings dialog box: Application File Name is the name used for the application executable file. By default, the extension uses the name of the Dreamweaver site to name the file. You can change the name if you prefer. However, the name must contain only valid characters for files or folder names. (That is, it can only contain ASCII characters, and cannot end with a period.) This setting is required. Application Name is the name that appears on installation screens when users install the application. Again, the extension specifies the name of the Dreamweaver site by default. This setting does not have character restrictions, and is not required. Application ID identifies your application with a unique ID. You can change the default ID if you prefer. Do not
use spaces or special characters in the ID. The only valid characters are 0-9, a-z, A-Z, . (dot), and - (dash). This setting is required. Version specifies a version number for your application. This setting is required. Initial Content specifies the start page for your application. Click the Browse button to navigate to your start page
and select it. The chosen file must reside inside the site root folder. This setting is required. Description lets you specify a description of the application to display when the user installs the application. Copyright lets you specify a copyright that is displayed in the About information for Adobe AIR applications
installed on the Macintosh. This information is not used for applications installed on Windows. Window Style specifies the window style (or chrome) to use when the user runs the application on their computer. System chrome surrounds the application with the operating system standard window control. Custom chrome (opaque) eliminates the standard system chrome and lets you create a chrome of your own for the application. (You build the custom chrome directly in the packaged HTML page.) Custom chrome (transparent) is like Custom chrome (opaque), but adds transparent capabilities to the edges of the page, allowing for application windows that are not rectangular in shape. Window Size specifies the dimensions of your application window when it opens. Icon lets you select custom images for the application icons. (The default images are Adobe AIR images that come
with the extension.) To use custom images, click the Select Icon Images button. Then, in the Icon Images dialog box that appears, click the folder for each icon size and select the image file you want to use. AIR only supports PNG files for application icon images. Note: Selected custom images must reside in the application site, and their paths must be relative to the site root. Associated File Types lets you associate file types with your application. For more information, see the section that
follows.
Last updated 3/28/2012
363
USING DREAMWEAVER Working with other applications
Application Updates determines whether the Adobe AIR Application Installer or the application itself performs
updates to new versions of Adobe AIRapplications. The check box is selected by default, which causes the Adobe AIR Application Installer to perform updates. If you want your application to perform its own updates, deselect the checkbox. Keep in mind that if you deselect the checkbox, you then need to write an application that can perform updates. Included Files specifies which files or folders to include in your application. You can add HTML and CSS files, image files, and JavaScript library files. Click the Plus (+) button to add files, and the folder icon to add folders. You should not include certain files such as _mmServerScripts, _notes, and so on. To delete a file or folder from your list, select the file or folder and click the Minus (-) button. Digital Signature Click Set to sign your application with a digital signature. This setting is required. For more
information, see the section that follows. Program Menu Folder specifies a subdirectory in the Windows Start Menu where you want the application’s
shortcut created. (Not applicable on Macintosh.) Destination specifies where to save the new application installer (.air file). The default location is the site root. Click
the Browse button to select a different location. The default file name is based on the site name with an .air extension added to it. This setting is required. The following is an example of the dialog box with some basic options set:
Last updated 3/28/2012
364
USING DREAMWEAVER Working with other applications
Signing an application with a digital certificate A digital signature provides an assurance that the code for an application has not been altered or corrupted since its creation by the software author. All Adobe AIR applications require a digital signature, and can’t be installed without one. You can sign your application with a purchased digital certificate, create your own certificate, or prepare an Adobe AIRI file (an Adobe AIR intermediate file) that you’ll sign at a later time. 1 In the AIR Application and Installer Settings dialog box, click the Set button next to the Digital Signature option. 2 In the Digital Signature dialog box, do one of the following:
• To sign an application with a pre-purchased digital certificate, click the Browse button, select the certificate, enter the corresponding password, and click OK.
• To create your own self-signed digital certificate, click the Create button and complete the dialog box. The certificate Type option refers to the level of security: 1024-RSA uses a 1024-bit key (less secure), and 2048-RSA uses a 2048-bit key (more secure). When you’re finished click OK. Then enter the corresponding password in the Digital Signature dialog box and click OK.
• Select Prepare an AIRI package that will be signed later and click OK. This option lets you create an AIR Intermediate (AIRI) application without a digital signature. A user is not able to install the application, however, until you add a digital signature.
About Timestamping When you sign an Adobe AIR application with a digital certificate, the packaging tool queries the server of a timestamp authority to obtain an independently verifiable date and time of signing. The timestamp obtained is embedded in the AIR file. As long as the signing certificate is valid at the time of signing, the AIR file can be installed, even after the certificate has expired. On the other hand, if no timestamp is obtained, the AIR file ceases to be installable when the certificate expires or is revoked. By default, the Adobe AIR Extension for Dreamweaver obtains a timestamp when creating an Adobe AIR application. You can, however, turn timestamping off by deselecting the Timestamp option in the Digital Signature dialog box. (You might want to do this, for example, if a timestamping service is unavailable.) Adobe recommends that all publically distributed AIR files include a timestamp. The default timestamp authority used by the AIR packaging tools is Geotrust. For more information on timestamping and digital certificates, see Digitally signing an AIR file.
Editing associated AIR file types You can associate different file types with your Adobe AIR application. For example, if you want file types with an .avf extension to open in Adobe AIR when a user double-clicks them, you can add the .avf extension to your list of associated file types. 1 In the AIR Application and Installer Settings dialog box, click the Edit list button next to the Associated File Types
option. 2 In the Associated File Types dialog box, do one of the following:
• Select a file type and click the minus (-) button to delete the file type. • Click the plus (+) button to add a file type. If you click the plus button to add a file type, the File Type Settings dialog box appears. Complete the dialog box and click OK to close it.
Last updated 3/28/2012
365
USING DREAMWEAVER Working with other applications
Following is a list of options: Name specifies the name of the file type that appears in the Associated File Types list. This option is required,
and can only include alphanumeric ASCII characters (a-z, A-Z, 0-9) and dots (for example, adobe.VideoFile). The name must start with a letter. The maximum length is 38 characters. Extension specifies the extension of the file type. Do not include a preceding dot. This option is required, and
can only include alphanumeric ASCII characters (a-z, A-Z, 0-9). The maximum length is 38 characters. Description lets you specify an optional description for the file type. Content Type specifies the MIME type or media type for the file (for example text/html, image/gif, and so on). Icon File Locations lets you select custom images for the associated file types. (The default images are Adobe
AIR images that come with the extension.)
Editing AIR application settings You can edit the settings for your Adobe AIR application at any time. ❖ Select Site > AIR Application Settings and make your changes.
Previewing a web page in an AIR application You can preview an HTML page in Dreamweaver as it would appear in an Adobe AIR application. Previewing is useful when you want to see what a web page will look like in the application without having to create the entire application. ❖ On the Document toolbar, click the Preview/Debug in Browser button, and then select Preview In AIR.
You can also press Ctrl+Shift+F12 (Windows) or Cmd+Shift+F12 (Macintosh).
Using AIR code hinting and code coloring The Adobe AIR Extension for Dreamweaver also adds code hinting and code coloring for Adobe AIR language elements in Code view in Dreamweaver. ❖ Open an HTML or JavaScript file in Code view and enterAdobe AIR code.
Note: The code hinting mechanism only works inside tags, or in .js files. For more information on the Adobe AIR language elements, see the developer documentation in the rest of this guide.
Accessing the Adobe AIR documentation The Adobe AIR extension adds a Help menu item in Dreamweaver that lets you access Developing AIR Applications with HTML and Ajax. ❖ Select Help > Adobe AIR Help.
Last updated 3/28/2012
366
Chapter 14: Creating and managing templates About Dreamweaver templates Understanding Dreamweaver templates A template is a special type of document that you use to design a “fixed” page layout; you can then create documents based on the template that inherit its page layout. As you design a template, you specify as “editable” which content users can edit in a document based on that template. Templates enable template authors to control which page elements template users—such as writers, graphic artists, or other web developers—can edit. There are several types of template regions the template author can include in a document. Note: Templates enable you to control a large design area and reuse complete layouts. If you want to reuse individual design elements, such as a site’s copyright information or a logo, create library items. Using templates enables you to update multiple pages at once. A document that is created from a template remains connected to that template (unless you detach the document later). You can modify a template and immediately update the design in all documents based on it. Note: Templates in Dreamweaver differ from templates in some other Adobe Creative Suite software in that page sections of Dreamweaver templates are fixed (or uneditable) by default.
More Help topics “Managing assets and libraries” on page 104 “Creating a Dreamweaver template” on page 374
Types of template regions When you save a document as a template, most regions of a document are locked. As a template author, you specify which regions of a template-based document will be editable by inserting editable regions or editable parameters in the template. As you create the template, you can make changes to both editable and locked regions. In a document based on the template, however, a template user can make changes only in the editable regions; the locked regions can’t be modified. There are four types of template regions: An editable region An unlocked region in a template-based document—a section a template user can edit. A template
author can specify any area of a template as editable. For a template to be effective, it should contain at least one editable region; otherwise, pages based on the template can’t be edited. A repeating region A section of the document layout that is set so that the template user can add or delete copies of
the repeating region in a document based on the template as necessary. For example, you can set a table row to repeat. Repeating sections are editable so that the template user can edit the content in the repeating element, while the design itself is under the control of the template author. There are two types of repeating regions you can insert in a template: repeating region and repeating table.
Last updated 3/28/2012
367
USING DREAMWEAVER Creating and managing templates
An optional region A section of a template that holds content—such as text or an image—that may or may not appear in a document. In the template-based page, the template user usually controls whether the content is displayed. An editable tag attribute Lets you unlock a tag attribute in a template, so the attribute can be edited in a template-
based page. For example, you can “lock” which image appears in the document but let the template user set the alignment to left, right, or center.
More Help topics “Editing content in a template-based document” on page 393 “Creating editable regions in templates” on page 377 “Creating repeating regions in templates” on page 378 “Using optional regions in templates” on page 381 “Defining editable tag attributes in templates” on page 383
Links in templates When you create a template file by saving an existing page as a template, the new template in the Templates folder, and any links in the file are updated so that their document-relative paths are correct. Later, when you create a document based on that template and save it, all the document-relative links are updated again to continue to point to the correct files. When you add a new document-relative link to a template file, it’s easy to enter the wrong path name if you type the path into the link text box in the Property inspector. The correct path in a template file is the path from the Templates folder to the linked document, not the path from the template-based document’s folder to the linked document. Ensure that the correct paths for links exist by using either the folder icon or the Point-to-file icon in the Property inspector when creating links in templates. Dreamweaver 8.01 link update preference Previous to Dreamweaver 8 (that is, Dreamweaver MX 2004 and earlier), Dreamweaver did not update links to files that resided in the Templates folder. (For example, if you had a file called main.css in the Templates folder, and had written href="main.css" as a link in the template file, Dreamweaver would not update this link when creating a template-based page.) Some users took advantage of the way Dreamweaver treated links to files in the Templates folder, and used this inconsistency to create links that they intentionally did not want to update when creating template-based pages. For example, if you are using Dreamweaver MX 2004, and have a site with different folders for different applications— Dreamweaver, Flash, and Photoshop. Each product folder contains a template-based index.html page, and a unique version of the main.css file at the same level. If the template file contains the document-relative link href="main.css" (a link to a version of the main.css file in the Templates folder), and you want your template-based index.html pages also to contain this link as written, you can create the template-based index.html pages without having to worry about Dreamweaver updating those particular links. When Dreamweaver MX 2004 creates the template-based index.html pages, the (un-updated) href="main.css" links refer to the main.css files that reside in the Dreamweaver, Flash, and Photoshop folders, not to the main.css file that resides in the Templates folder.
Last updated 3/28/2012
368
USING DREAMWEAVER Creating and managing templates
In Dreamweaver 8, however, this behavior was changed so that all document-relative links are updated when creating template-based pages, regardless of the apparent location of the linked files. In this scenario, Dreamweaver examines the link in the template file (href="main.css") and creates a link in the template-based page that is relative to the location of the new document. For example, if you are creating a template-based document one level up from the Templates folder, Dreamweaver would write the link in the new document as href="Templates/main.css". This update in Dreamweaver 8 broke links in pages created by those designers who had taken advantage of Dreamweaver’s former practice of not updating links to files in the Templates folder. Dreamweaver 8.01 added a preference that enables you to turn the update relative links behavior on and off. (This special preference only applies to links to files in the Templates folder, not to links in general.) The default behavior is to not update these links (as in Dreamweaver MX 2004 and before), but if you want Dreamweaver to update these kinds of links when creating template-based pages, you can deselect the preference. (You would only do this if, for example, you had a Cascading Style Sheets (CSS) page, main.css, in your Templates folder, and you wanted a template-based document to contain the link href="Templates/main.css"; but this is not recommended practice as only Dreamweaver template (DWT) files should reside in the Templates folder.) To have Dreamweaver update document-relative paths to non-template files in the Templates folder, select the Templates category in the Site Setup dialog box (it’s under Advanced Settings), and deselect the Don’t Rewrite Document Relative Paths option. For more information, see the Dreamweaver TechNote on the Adobe website at www.adobe.com/go/f55d8739.
More Help topics “Link to documents using the Point-To-File icon” on page 261 “Document-relative paths” on page 258
Server scripts in templates and template-based documents Some server scripts are inserted at the very beginning or end of the document (before the tag or after the tag). Such scripts require special treatment in templates and template-based documents. Normally, if you make changes to script code before the tag or after the tag in a template, the changes are not copied to documents based on that template. This can cause server errors if other server scripts, within the main body of the template, depended on the scripts that are not copied. An alert warns you if you change scripts before the tag or after the tag in a template. To avoid this problem, you can insert the following code in the head section of the template:
When this code is in a template, changes to scripts before the tag or after the tag are copied to documents based on that template. However, you will no longer be able to edit those scripts in documents based on the template. Thus, you can choose to either edit these scripts in the template, or in documents based on the template, but not both.
Template parameters Template parameters indicate values for controlling content in documents based on a template. Use template parameters for optional regions or editable tag attributes, or to set values you want to pass to an attached document. For each parameter, you select a name, a data type, and a default value. Each parameter must have a unique name that is case sensitive. They must be one of five permitted data types: text, boolean, color, URL, or number.
Last updated 3/28/2012
369
USING DREAMWEAVER Creating and managing templates
Template parameters are passed to the document as instance parameters. In most cases, a template user can edit the parameter’s default value to customize what appears in a template-based document. In other cases, the template author might determine what appears in the document, based on the value of a template expression.
More Help topics “Using optional regions in templates” on page 381 “Defining editable tag attributes in templates” on page 383
Template expressions Template expressions are statements that compute or evaluate a value. You can use an expression to store a value and display it in a document. For example, an expression can be as simple as the value of a parameter, such as @@(Param)@@, or complex enough to compute values which alternate the background color in a table row, such as @@((_index & 1) ? red : blue)@@. You can also define expressions for if and multiple-if conditions. When an expression is used in a conditional statement, Dreamweaver evaluates it as true or false. If the condition is true, the optional region appears in the template-based document; if it is false, it doesn’t appear. You can define expressions in Code view or in the Optional Region dialog box when you insert an optional region. In Code view, there are two ways to define template expressions: use the comment or @@(your expression)@@. When you insert the expression in the template code, an expression marker appears in Design view. When you apply the template, Dreamweaver evaluates the expression and displays the value in the template-based document.
More Help topics “Template expression language” on page 369 “Multiple If condition in template code” on page 370
Template expression language The template expression language is a small subset of JavaScript, and uses JavaScript syntax and precedence rules. Use JavaScript operators to write an expression like this: @@(firstName+lastName)@@
The following features and operators are supported:
• numeric literals, string literals (double-quote syntax only), Boolean literals (true or false) • variable reference (see the list of defined variables later in this section) • field reference (the “dot” operator) • unary operators: +, -, ~, ! • binary operators: +, -, *, /, %, &, |, ^, &&, ||, =, ==, !=, • conditional operator: ?: • parentheses: ()
Last updated 3/28/2012
370
USING DREAMWEAVER Creating and managing templates
The following data types are used: Boolean, IEEE 64-bpc floating point, string, and object. Dreamweaver templates do not support the use of JavaScript “null” or “undefined” types. Nor do they allow scalar types to be implicitly converted into an object; thus, the expression "abc".length would trigger an error, instead of yielding the value 3. The only objects available are those defined by the expression object model. The following variables are defined: _document Contains the document-level template data with a field for each parameter in the template. _repeat Only defined for expressions which appear inside a repeating region. Provides built-in information about the region _index The numerical index (from 0) of the current entry _numRows The total number of entries in this repeating region _isFirst True if the current entry is the first entry in its repeating region _isLast True if the current entry is the last entry in its repeating region _prevRecord The _repeat object for the previous entry. It is an error to access this property for the first entry in
the region. _nextRecord The _repeat object for the next entry. It is an error to access this property for the last entry in the
region. _parent In a nested repeated region, this gives the _repeat object for the enclosing (outer) repeated region. It is an error to access this property outside of a nested repeated region.
During expression evaluation, all fields of the _document object and _repeat object are implicitly available. For example, you can enter title instead of _document.title to access the document’s title parameter. In cases where there is a field conflict, fields of the _repeat object take precedence over fields of the _document object. Therefore, you shouldn’t need to explicitly reference _document or _repeat except that _document might be needed inside a repeating region to reference document parameters that are hidden by repeated region parameters. When nested repeated regions are used, only fields of the innermost repeated regions are available implicitly. Outer regions must be explicitly referenced using _parent.
Multiple If condition in template code You can define template expressions for if and multiple-if conditions. This example demonstrates defining a parameter named "Dept", setting an initial value, and defining a multiple-if condition which determines which logo to display. The following is an example of the code you might enter in the head section of the template:
The following condition statement checks the value assigned to the Dept parameter. When the condition is true or matches, the appropriate image is displayed.
Last updated 3/28/2012
371
USING DREAMWEAVER Creating and managing templates
TemplateEndIfClause --> TemplateEndIfClause--> TemplateEndIfClause --> TemplateEndIfClause -->
image-->
You can use code color preferences to set your own color scheme so you can easily distinguish template regions when you view a document in Code view. Everything between these comments will be editable in documents based on the template. The HTML source code for an editable region might look like this: Name | Address | Telephone Number | Enter name | Enter Address | Enter Telephone |
Note: When you edit template code in Code view, be careful not to change any of the template-related comment tags that Dreamweaver relies on.
More Help topics “Customize code coloring preferences for a template” on page 397
Recognizing template-based documents in Design view In a document based on a template (a template-based document), editable regions appear in the Design view of the Document window surrounded by rectangular outlines in a preset highlight color. A small tab appears at the upperleft corner of each region, showing the name of the region.
Last updated 3/28/2012
373
USING DREAMWEAVER Creating and managing templates
In addition to the editable-region outlines, the entire page is surrounded by a different-colored outline, with a tab in the upper-right corner giving the name of the template that the document is based on. This highlighted rectangle reminds you that the document is based on a template and that you can’t change content outside the editable regions.
More Help topics “Set highlighting preferences for template regions” on page 397
Recognizing template-based documents in Code view In Code view, editable regions of a document derived from a template appear in a different color than code in the noneditable regions. You can make changes only to code in the editableregions or editable parameters but you cannot type in locked regions. Editable content is marked in HTML with the following Dreamweaver comments:
Everything between these comments is editable in a template-based document. The HTML source code for an editable region might look like this:
Last updated 3/28/2012
374
USING DREAMWEAVER Creating and managing templates
Name | Address | Telephone Number | Enter name | Enter Address | Enter Telephone |
The default color for non-editable text is gray; you can select a different color for the editable and non-editable regions in the Preferences dialog box.
More Help topics “Customize code coloring preferences for a template” on page 397
Creating a Dreamweaver template About creating Dreamweaver templates You can create a template from an existing document (such as an HTML, Adobe ColdFusion, or Microsoft Active Server Pages document) or you can create a template from a new document. After you create a template, you can insert template regions, and set template preferences for code color and template region highlight color. You can store additional information about a template (such as who created it, when it was last changed, or why you made certain layout decisions) in a Design Notes file for the template. Documents based on a template do not inherit the template’s Design Notes. Note: Templates in Adobe Dreamweaver differ from templates in some other Adobe Creative Suite products in that page sections of Dreamweaver templates are fixed (or uneditable) by default. For a tutorial on creating templates, see www.adobe.com/go/vid0157. For a tutorial on using templates, see www.adobe.com/go/vid0158.
More Help topics “Types of template regions” on page 366 “Setting authoring preferences for templates” on page 397 “Associate Design Notes with files” on page 99 Creating templates tutorial Using templates tutorial
Last updated 3/28/2012
375
USING DREAMWEAVER Creating and managing templates
Create a template from an existing document You can create a template from an existing document. 1 Open the document you want to save as a template. 2 Do one of the following:
• Select File > Save As Template. • In the Common category of the Insert panel, click the Templates button, then select Make Template from the popup menu. Note: Unless you selected Don’t Show This Dialog Again in the past, you’ll receive a warning that says the document you’re saving has no editable regions. Click OK to save the document as a template, or click Cancel to exit this dialog box without creating a template. 3 Select a site to save the template in from the Site pop-up menu, and then enter a unique name for the template in
the Save As box. 4 Click Save. Dreamweaver saves the template file in the site’s Templates folder in the local root folder of the site, with
a .dwt filename extension. If the Templates folder does not already exist in the site, Dreamweaver automatically creates it when you save a new template. Note: Do not move your templates out of the Templates folder, or put any non-template files in the Templates folder. Also, do not move the Templates folder out of your local root folder. Doing so causes errors in paths in the templates.
More Help topics “Create a blank template” on page 59 “Creating and opening documents” on page 57
Use the Assets panel to create a new template 1 In the Assets panel (Window > Assets), select the Templates category on the left side of the panel 2 Click the New Template button
.
at the bottom of the Assets panel.
A new, untitled template is added to the list of templates in the Assets panel. 3 While the template is still selected, enter a name for the template, then press Enter (Windows) or Return
(Macintosh). Dreamweaver creates a blank template in the Assets panel and in the Templates folder.
About creating templates for Contribute sites Using Dreamweaver, you can create templates to help Adobe® Contribute® users create new pages, to provide a consistent look and feel for your site, and to enable you to update the layout of many pages at once. When you create a template and upload it to the server, it becomes available to all Contribute users who connect to your site, unless you’ve set restrictions on template use for certain Contribute roles. If you have set restrictions on template use, you might need to add each new template to the list of templates a Contribute user can use (see Administering Contribute). Note: Make sure that the site root folder defined in each Contribute user’s site definition is the same as the site root folder defined in your site definition in Dreamweaver. If a user’s site root folder doesn’t match yours, that user won’t be able to use templates.
Last updated 3/28/2012
376
USING DREAMWEAVER Creating and managing templates
In addition to Dreamweaver templates, you can create non-Dreamweaver templates using the Contribute administration tools. A non-Dreamweaver template is an existing page that Contribute users can use to create new pages; it’s similar to a Dreamweaver template, except that pages that are based on it don’t update when you change the template. Also, non-Dreamweaver templates can’t contain Dreamweaver template elements such as editable, locked, repeating, and optional regions. When a Contribute user creates a new document within a site containing Dreamweaver templates, Contribute lists the available templates (both Dreamweaver and non-Dreamweaver templates) in the New Page dialog box.
To include pages that use encodings other than Latin-1 in your site, you might need to create templates (either Dreamweaver templates or non-Dreamweaver templates). Contribute users can edit pages that use any encoding, but when a Contribute user creates a new blank page, it uses the Latin-1 encoding. To create a page that uses a different encoding, a Contribute user can create a copy of an existing page that uses a different encoding, or can use a template that uses a different encoding. However, if there are no pages or templates in the site that use other encodings, then you must first create a page or a template in Dreamweaver that uses that other encoding.
Create a template for a Contribute site 1 Select Site > Manage Sites. 2 Select a site and click Edit. 3 In the Site Setup dialog box, select the Contribute category. 4 If you haven’t already done so, you need to enable Contribute compatibility.
Select Enable Contribute Compatibility, and then enter a site root URL. 5 Click Administer Site In Contribute. 6 If prompted, enter the administrator password, and then click OK. 7 In the Users And Roles category, select a role, and then click the Edit Role Settings button.
Last updated 3/28/2012
377
USING DREAMWEAVER Creating and managing templates
8 Select the New Pages category, and then add existing pages to the list under Create A New Page By Copying A Page
From This List. For more information, see Administering Contribute. 9 Click OK twice to close the dialog boxes.
More Help topics “Prepare a site for use with Contribute” on page 52
Creating editable regions in templates Insert an editable region Editable template regions control which areas of a template-based page a user can edit. Before you insert an editable region, save the document you are working in as a template. Note: If you insert an editable region in a document rather than a template file, an alert warns you that the document will automatically be saved as a template. You can place an editable region anywhere in your page, but consider the following points if you are making a table or an absolutely-positioned element (AP element) editable:
• You can mark an entire table or an individual table cell as editable, but you can’t mark multiple table cells as a single editable region. If a | tag is selected, the editable region includes the region around the cell; if not, the editable region affects only content inside the cell.
• AP elements and AP element content are separate elements; making an AP element editable lets you change the position of the AP element as well as its contents, but making an AP element’s contents editable lets you change only the content of the AP element, not its position. 1 In the Document window, do one of the following to select the region:
• Select the text or content that you want to set as an editable region. • Place the insertion point where you want to insert an editable region. 2 Do one of the following to insert an editable region:
• Select Insert > Template Objects > Editable Region. • Right-click (Windows) or Control-click (Macintosh), then select Templates > New Editable Region. • In the Common category of the Insert panel, click the Templates button, then select Editable Region from the popup menu. 3 In the Name box, enter a unique name for the region. (You cannot use the same name for more than one editable
region in a particular template.) Note: Do not use special characters in the Name box. 4 Click OK. The editable region is enclosed in a highlighted rectangular outline in the template, using the
highlighting color that is set in preferences. A tab at the upper-left corner of the region shows the name of the region. If you insert an empty editable region in the document, the name of the region also appears inside the region.
Last updated 3/28/2012
378
USING DREAMWEAVER Creating and managing templates
More Help topics “Creating a Dreamweaver template” on page 374 “Set highlighting preferences for template regions” on page 397
Select editable regions You can easily identify and select template regions in both the template document and template-based documents.
Select an editable region in the Document window ❖ Click the tab in the upper-left corner of the editable region.
Find an editable region and select it in the document ❖ Select Modify > Templates, then select the name of the region from the list at the bottom of that submenu.
Note: Editable regions that are inside a repeated region do not appear in the menu. You must locate these regions by looking for tabbed borders in the Document window. The editable region is selected in the document.
Remove an editable region If you’ve marked a region of your template file as editable and you want to lock it (make it noneditable in templatebased documents) again, use the Remove Template Markup command. 1 Click the tab in the upper-left corner of the editable region to select it. 2 Do one of the following:
• Select Modify > Templates > Remove Template Markup. • Right-click (Windows) or Control-click (Macintosh), then select Templates > Remove Template Markup. The region is no longer editable.
Change an editable region’s name After you insert an editable region, you can later change its name. 1 Click the tab in the upper-left corner of the editable region to select it. 2 In the Property inspector (Window > Properties), enter a new name. 3 Press Enter (Windows) or Return (Macintosh).
Creating repeating regions in templates About template repeating regions A repeating region is a section of a template that can be duplicated many times in a template-based page. Typically, repeating regions are used with tables but you can define a repeating region for other page elements. Repeating regions enable you to control your page layout by repeating certain items, such as a catalog item and description layout, or a row for data such as a list of items.
Last updated 3/28/2012
379
USING DREAMWEAVER Creating and managing templates
There are two repeating region template objects you can use: repeating region and repeating table.
More Help topics “Types of template regions” on page 366
Create a repeating region in a template Repeating regions enable template users to duplicate a specified region in a template as often as desired. A repeating region is not necessarily an editable region. To make content in a repeating region editable (for example, to allow a user to enter text in a table cell in a templatebased document), you must insert an editable region in the repeating region. 1 In the Document window, do one of the following:
• Select the text or content you want to set as a repeating region. • Place the insertion point in the document where you want to insert the repeating region. 2 Do one of the following:
• Select Insert > Template Objects > Repeating Region. • Right-click (Windows) or Control-click (Macintosh), then select Templates > New Repeating Region. • In the Common category of the Insert panel, click the Templates button, then select Repeating Region from the pop-up menu. 3 In the Name box, enter a unique name for the template region. (You cannot use the same name for more than one
repeating region in a template.) Note: When you name a region, do not use special characters. 4 Click OK.
More Help topics “Insert an editable region” on page 377
Insert a repeating table You can use a repeating table to create an editable region (in table format) with repeating rows. You can define table attributes and set which table cells are editable. 1 In the Document window, place the insertion point in the document where you want to insert the repeating table. 2 Do one of the following:
• Select Insert > Template Objects > Repeating Table. • In the Common category of the Insert panel, click the Templates button, and then select Repeating Table from the pop-up menu. 3 Specify the following options and click OK. Rows Determines the number of rows the table has. Columns Determines the number of columns the table has. Cell Padding Determines the number of pixels between a cell’s content and the cell boundaries. Cell Spacing Determines the number of pixels between adjacent table cells.
Last updated 3/28/2012
380
USING DREAMWEAVER Creating and managing templates
If you don’t explicitly assign values for cell padding and cell spacing, most browsers display the table as if cell padding were set to 1 and cell spacing were set to 2. To ensure that browsers display the table with no padding or spacing, set Cell Padding and Cell Spacing to 0. Width Specifies the width of the table in pixels, or as a percentage of the browser window’s width. Border Specifies the width, in pixels, of the table’s borders.
If you don’t explicitly assign a value for border, most browsers display the table as if the border were set to 1. To ensure that browsers display the table with no border, set Border to 0. To view cell and table boundaries when the border is set to 0, select View > Visual Aids > Table Borders. Repeat Rows of the Table Specify which rows in the table are included in the repeating region. Starting Row Sets the row number entered as the first row to include in the repeating region. Ending Row Sets the row number entered as the last row to include in the repeating region. Region Name Lets you set a unique name for the repeating region.
Set alternating background colors in a repeating table After you insert a repeating table in a template, you can customize it by alternating the background color of the table rows. 1 In the Document window, select a row in the repeating table. 2 Click the Show Code View or Show Code And Design Views button in the Document toolbar so you can access the
code for the selected table row. 3 In Code view, edit the | tag to include the following code:
You can replace the #FFFFFF and #CCCCCC hexadecimal values with other color choices. 4 Save the template.
The following is a code example of a table that includes alternating background table row colors: Name | Phone Number | Email Address | name | phone | email |
Last updated 3/28/2012
381
USING DREAMWEAVER Creating and managing templates
Using optional regions in templates About template optional regions An optional region is a region in a template that users can set to show or to hide in a template-based document. Use an optional region when you want to set conditions for displaying content in a document. When you insert an optional region, you can either set specific values for a template parameter or define conditional statements (If...else statements) for template regions. Use simple true/false operations, or define more complex conditional statements and expressions. You can later modify the optional region if necessary. Based on the conditions you define, template users can edit the parameters in template-based documents they create and control whether the optional region is displayed. You can link multiple optional regions to a named parameter. In the template-based document, both regions will show or hide as a unit. For example, you can show a “closeout” image and sales price text area for a sale item.
More Help topics “Modify template properties” on page 393 “Types of template regions” on page 366
Insert an optional region Use an optional region to control content that may or may not be displayed in a template-based document. There are two types of optional regions:
• Non-editable optional regions, which enable template users to show and hide specially marked regions without enabling them to edit the content. The template tab of an optional region is preceded by the word if. Based on the condition set in the template, a template user can define whether the region is viewable in pages they create.
• Editable optional regions, which enable template users to set whether the region shows or hides, and enable users to edit content in the region. For example, if the optional region includes an image or text, the template user can set whether the content is displayed, as well as make edits to the content if desired. An editable region is controlled by a conditional statement.
More Help topics “Modify template properties” on page 393
Insert a non-editable optional region 1 In the Document window, select the element you want to set as an optional region. 2 Do one of the following:
• Select Insert > Template Objects > Optional Region. • Right-click (Windows) or Control-click (Macintosh) the selected content, then select Templates > New Optional Region.
• In the Common category of the Insert panel, click the Templates button, then select Optional Region from the popup menu.
Last updated 3/28/2012
382
USING DREAMWEAVER Creating and managing templates
3 Enter a name for the optional region, click the Advanced tab if you want to set values for the optional region, and
then click OK.
Insert an editable optional region 1 In the Document window, place the insertion point where you want to insert the optional region.
You cannot wrap a selection to create an editable optional region. Insert the region, then insert the content in the region. 2 Do one of the following:
• Select Insert > Template Objects > Editable Optional Region. • In the Common category of the Insert panel, click the Templates button, then select Editable Optional Region from the pop-up menu. 3 Enter a name for the optional region, click the Advanced tab if you want to set values for the optional region, and
click OK.
Set values for an optional region You can edit optional region settings after you’ve inserted the region in a template. For example, you can change whether the default setting for the content is to be displayed or not, to link a parameter to an existing optional region, or to modify a template expression. Create template parameters and define conditional statements (If...else statements) for template regions. You can use simple true/false operations, or define more complex conditional statements and expressions. In the Advanced tab you can link multiple optional regions to a named parameter. In the template-based document, both regions will show or hide as a unit. For example, you can show a “closeout” image and sales price text area for a sale item. You can also use the Advanced tab to write a template expression that evaluates a value for the optional region and shows it or hides it based on the value. 1 In the Document window, do one of the following:
• In Design view, click the template tab of the optional region you want to modify. • In Design view, place the insertion point in the template region; then in the tag selector at the bottom of the Document window, select the template tag, .
• In Code view, click the comment tag of the template region you want to modify. 2 In the Property inspector (Window > Properties), click Edit. 3 In the Basics tab, enter a name for the parameter in the Name box. 4 Select Show By Default to set the selected region to show in the document. Deselect it to set the default value to false.
Note: To set a different value for the parameter, in Code view locate the parameter in the section of the document and edit the value. 5 (Optional) Click the Advanced tab, then set the following options:
• If you want to link optional region parameters, click the Advanced tab, select Use Parameter, then from the pop-up menu select the existing parameter you want to link the selected content to.
• If you want to write a template expression to control the display of an optional region, click the Advanced tab, select Enter Expression, then enter the expression in the box. Note: Dreamweaver inserts double-quotation marks around the text you enter.
Last updated 3/28/2012
383
USING DREAMWEAVER Creating and managing templates
6 Click OK.
When you use the Optional Region template object, Dreamweaver inserts template comments in the code. A template parameter is defined in the head section, as in the following example:
At the location where the optional region is inserted, code similar to the code below appears:
You can access and edit template parameters in the template-based document.
More Help topics “Modify template properties” on page 393 “Template expressions” on page 369
Defining editable tag attributes in templates Specify editable tag attributes in a template You can allow a template user to modify specified tag attributes in a document created from a template. For example, you can set a background color in the template document, yet enable template users to set a different background color for pages they create. Users can update only the attributes you specify as editable. You can also set multiple editable attributes in a page so that template users can modify the attributes in templatebased documents. The following data types are supported: text, Boolean (true/false), color, and URL. Creating an editable tag attribute inserts a template parameter in the code. An initial value for the attribute is set in the template document; when a template-based document is created, it inherits the parameter. A template user can then edit the parameter in the template-based document. Note: If you make the link to a style sheet an editable attribute, then the attributes of the style sheet are no longer available for either viewing or editing in the template file. 1 In the Document window, select an item you want to set an editable tag attribute for. 2 Select Modify > Templates > Make Attribute Editable. 3 In the Attribute box, enter a name or select an attribute in the Editable Tag Attributes dialog box by doing one of
the following:
• If the attribute you want to make editable is listed in the Attribute pop-up menu, select it. • If the attribute you want to make editable isn’t listed in the Attribute pop-up menu, click Add, and in the dialog box that opens, enter the name of the attribute you want to add, then click OK. 4 Make sure the Make Attribute Editable option is selected. 5 In the Label box, enter a unique name for the attribute.
To make it easier to identify a specific editable tag attribute later, use a label that identifies the element and the attribute. For example, you might label an image whose source is editable logoSrc or label the editable background color of a body tag bodyBgcolor.
Last updated 3/28/2012
384
USING DREAMWEAVER Creating and managing templates
6 In the Type menu, select the type of value allowed for this attribute by setting one of the following options:
• To enable a user to enter a text value for the attribute, select Text. For example, you can use text with the align attribute; the user can then set the attribute’s value to left, right, or center.
• To insert a link to an element, such as the file path to an image, select URL. Using this option automatically updates the path used in a link. If the user moves the image to a new folder, the Update Links dialog box appears.
• To make the color picker available for selecting a value, select Color. • To enable a user to select a true or false value on the page, select True/False. • To enable a template user to type a numerical value to update an attribute (for example, to change the height or width values of an image), select Number. 7 The Default Value box displays the value of the selected tag attribute in the template. Enter a new value in this box
to set a different initial value for the parameter in the template-based document. 8 (Optional) If you want to make changes to another attribute of the selected tag, select the attribute and set the
options for that attribute. 9 Click OK.
More Help topics “Modify template properties” on page 393
Make an editable tag attribute uneditable A tag previously marked as editable can be marked as uneditable. 1 In the template document, click the element associated with the editable attribute or use the tag selector to select
the tag. 2 Select Modify > Templates > Make Attribute Editable. 3 In the Attributes pop-up menu, select the attribute you want to affect. 4 Deselect Make Attribute Editable and click OK. 5 Update documents based on the template.
Creating a nested template About nested templates A nested template is a template whose design and editable regions are based on another template. Nested templates are useful for controlling content in pages of a site that share many design elements, but have a few variations between pages. For example, a base template might contain broader design areas and be usable by many content contributors for a site, while a nested template might further define the editable regions in pages for a specific section in a site. Editable regions in a base template are passed through to the nested template, and remain editable in pages created from a nested template unless new template regions are inserted in these regions. Changes to a base template are automatically updated in templates based on the base template, and in all templatebased documents that are based on the main and nested templates.
Last updated 3/28/2012
385
USING DREAMWEAVER Creating and managing templates
In the following example, the template trioHome contains three editable regions, named Body, NavBar, and Footer:
To create a nested template, a new document based on the template was created and then saved as a template and named TrioNested. In the nested template, two editable regions have been added in the editable region named Body.
Last updated 3/28/2012
386
USING DREAMWEAVER Creating and managing templates
When you add a new editable region in an editable region passed through to the nested template, the highlighting color of the editable region changes to orange. Content you add outside the editable region, such as the graphic in the editableColumn, is no longer editable in documents based on the nested template. The blue highlighted editable areas, whether added in the nested template or passed through from the base template, remain editable in documents that are based on the nested template. Template regions that do not contain an editable region pass through to template-based documents as editable regions.
More Help topics Nested Templates
Create a nested template Nested templates let you create variations of a base template. You can nest multiple templates to define increasingly specific layouts. By default, all editable template regions from the base template pass through the nested template to the document based on the nested template. That means that if you create an editable region in a base template, then create a nested template, the editable region appears in documents based on the nested template (if you did not insert any new template regions in that region in the nested template). Note: You can insert template markup inside an editable region so that it won’t pass through as an editable region in documents based on the nested template. Such regions have an orange border instead of a blue border. 1 Create a document from the template on which you want to base the nested template by doing one of the following:
• In the Assets panel’s Templates category, right-click (Windows) or Control-click (Macintosh) the template you want to create a new document from, then select New From Template from the context menu.
• Select File > New. In the New Document dialog box, select the Page from Template category, then select the site that contains the template you want to use; in the Template list, double-click the template to create a new document. 2 Select File > Save As Template to save the new document as a nested template: 3 Enter a name in the Save As box and click OK.
More Help topics “Server scripts in templates and template-based documents” on page 368
Prevent an editable region from passing through to a nested template In nested templates, pass-through editable regions have a blue border. You can insert template markup inside an editable region so that it won’t pass through as an editable region in documents based on the nested template. Such regions have an orange border instead of a blue border. 1 In Code view, locate the editable region you want to prevent from passing through.
Editable regions are defined by template comment tags. 2 Add the following code to the editable region code: @@("")@@
This template code can be placed anywhere within the tags that surround the editable region. For
example:
Last updated 3/28/2012
387
USING DREAMWEAVER Creating and managing templates
@@("")@@ Editable 1
Editing, updating, and deleting templates About editing and updating templates When you make changes to and save a template, all the documents based on the template are updated. You can also manually update a template-based document or the entire site if necessary. Note: To edit a template for a Contribute site, you must use Dreamweaver; you cannot edit templates in Contribute. Use the Templates category of the Assets panel to manage existing templates, including renaming template files and deleting template files. You can perform the following template management tasks with the Assets panel:
• Create a template • Edit and update templates • Apply or remove a template from an existing document Dreamweaver checks template syntax when you save a template but it’s a good idea to manually check the template syntax while you’re editing a template.
More Help topics “Creating a Dreamweaver template” on page 374 “Check template syntax” on page 396 “Applying or removing a template from an existing document” on page 391
Open a template for editing You can open a template file directly for editing, or you can open a template-based document, then open the attached template for editing. When you make a change to a template, Dreamweaver prompts you to update the documents based on the template. Note: You can also manually update the documents for template changes if necessary.
More Help topics “Check template syntax” on page 396
Open and edit a template file 1 In the Assets panel (Window > Assets), select the Templates category on the left side of the panel
.
The Assets panel lists all of the available templates for your site and displays a preview of the selected template. 2 In the list of available templates, do one of the following:
• Double-click the name of the template you want to edit. • Select a template to edit, then click the Edit button
at the bottom of the Assets panel.
Last updated 3/28/2012
388
USING DREAMWEAVER Creating and managing templates
3 Modify the contents of the template.
To modify the template’s page properties, select Modify > Page Properties. (Documents based on a template inherit the template’s page properties.) 4 Save the template. Dreamweaver prompts you to update pages based on the template. 5 Click Update to update all documents based on the modified template; click Don’t Update if you don’t want to
update documents based on the modified template. Dreamweaver displays a log indicating the files that were updated.
Open and modify the template attached to the current document 1 Open the template-based document in the Document window. 2 Do one of the following:
• Select Modify > Templates > Open Attached Template. • Right-click (Windows) or Control-click (Macintosh), then select Templates > Open Attached Template. 3 Modify the contents of the template.
To modify the template’s page properties, select Modify > Page Properties. (Documents based on a template inherit the template’s page properties.) 4 Save the template. Dreamweaver prompts you to update pages based on the template. 5 Click Update to update all documents based on the modified template; click Don’t Update if you don’t want to
update documents based on the modified template. Dreamweaver displays a log indicating the files that were updated.
Rename a template 1 In the Assets panel (Window > Assets), select the Templates category on the left side of the panel
.
2 Click the name of the template to select it. 3 Click the name again so that the text is selectable, then enter a new name.
This method of renaming works in the same way as renaming a file in Windows Explorer (Windows) or the Finder (Macintosh). As with Windows Explorer and the Finder, be sure to pause briefly between clicks. Do not double-click the name, because that opens the template for editing. 4 Click in another area of the Asset panel, or press Enter (Windows) or Return (Macintosh) for the change to take
effect. An alert asks if you want to update documents that are based on this template. 5 To update all documents in the site that are based on this template, click Update. Click Don’t Update if you do not
want to update any document based on this template.
More Help topics “Creating a Dreamweaver template” on page 374 “Applying or removing a template from an existing document” on page 391
Last updated 3/28/2012
389
USING DREAMWEAVER Creating and managing templates
Change a template description The template description appears in the New Document dialog box when you’re creating a page from an existing template. 1 Select Modify > Templates > Description. 2 In the Template Description dialog box, edit the description and click OK.
More Help topics “Creating a Dreamweaver template” on page 374
Manually update documents based on templates When you make a change to a template, Dreamweaver prompts you to update the documents based on the template, but you can manually update the current document or the entire site if necessary. Manually updating template-based documents is the same as reapplying the template.
Apply template changes to the current template-based document 1 Open the document in the Document window. 2 Select Modify > Templates > Update Current Page.
Dreamweaver updates the document with any template changes.
Update the entire site or all documents that use a specified template You can update all the pages in the site, or only update pages for a specific template. 1 Select Modify > Templates > Update Pages. 2 In the Look In menu, do one of the following:
• To update all the files in the selected site to their corresponding templates, select Entire Site, then select the site name from the adjacent pop-up menu.
• To update files for a specific template, select Files That Use, then select the template name from the adjacent pop-up menu. 3 Make sure Templates is selected in the Update option. 4 If you don’t want to see a log of the files Dreamweaver updates, deselect the Show Log option; otherwise, leave that
option selected. 5 Click Start to update the files as indicated. If you selected the Show Log option, Dreamweaver provides information
about the files it attempts to update, including information on whether they were updated successfully. 6 Click Close.
Update templates in a Contribute site Contribute users can’t make changes to a Dreamweaver template. You can, however, use Dreamweaver to change a template for a Contribute site Keep these factors in mind when updating templates in a Contribute site:
• Contribute retrieves new and changed templates from the site only when Contribute starts up and when a Contribute user changes their connection information. If you make changes to a template while a Contribute user is editing a file based on that template, the user won’t see the changes to the template until they restart Contribute.
Last updated 3/28/2012
390
USING DREAMWEAVER Creating and managing templates
• If you remove an editable region from a template, a Contribute user editing a page based on that template might be confused about what to do with the content that was in that editable region. To update a template in a Contribute site, complete the following steps. 1 Open the Contribute template in Dreamweaver, edit it, and then save it. For instructions, see “Open a template for
editing” on page 387. 2 Notify all of the Contribute users who are working on the site to restart Contribute.
Delete a template file 1 In the Assets panel (Window > Assets), select the Templates category on the left side of the panel
.
2 Click the name of the template to select it. 3 Click the Delete button
at the bottom of the panel, then confirm that you want to delete the template.
Important: After you delete a template file, you can’t retrieve it. The template file is deleted from your site. Documents that are based on a deleted template are not detached from the template; they retain the structure and editable regions that the template file had before it was deleted. You can convert such a document into an HTML file without editable or locked regions.
More Help topics “Detach a document from a template” on page 392 “Applying or removing a template from an existing document” on page 391 “Creating a Dreamweaver template” on page 374
Exporting and importing template content About template XML content You can think of a document based on a template as containing data represented by name-value pairs. Each pair consists of the name of an editable region, and the contents of that region. You can export the name-value pairs into an XML file so that you can work with the data outside of Dreamweaver (for example, in an XML editor or a text editor, or a database application). Conversely, if you have an XML document that’s structured appropriately, you can import the data from it into a document based on a Dreamweaver template.
Export a document’s editable regions as XML 1 Open a template-based document that contains editable regions. 2 Select File > Export > Template Data As XML. 3 Select one of the Notation options:
• If the template contains repeating regions or template parameters, select Use Standard Dreamweaver XML Tag. • If the template does not contain repeating regions or template parameters, select Use Editable Region Names as XML Tags. 4 Click OK.
Last updated 3/28/2012
391
USING DREAMWEAVER Creating and managing templates
5 In the dialog box that appears, select a folder location, enter a name for the XML file, and then click Save.
An XML file is generated that contains the material from the document’s parameters and editable regions, including editable regions inside repeating regions or optional regions. The XML file includes the name of the original template, as well as the name and contents of each template region. Note: Content in the non-editable regions is not exported to the XML file.
Import XML content 1 Select File > Import > Import XML into Template. 2 Select the XML file and click Open.
Dreamweaver creates a new document based on the template specified in the XML file. It fills in the contents of each editable region in that document using the data from the XML file. The resulting document appears in a new Document window. If your XML file isn’t set up exactly the way Dreamweaver expects, you might not be able to import your data. One solution to this problem is to export a dummy XML file from Dreamweaver, so that you’ll have an XML file with exactly the right structure. Then copy the data from your original XML file into the exported XML file. The result is an XML file with the correct structure that contains the appropriate data, ready to be imported.
Export a site without template markup You can export template-based documents in a site to another site without including the template markup. 1 Select Modify > Templates > Export Without Markup. 2 In the Folder box, enter the file path to the folder you want to export the file to or click Browse and select the folder.
Note: You must select a folder outside of the current site. 3 If you want to save an XML version of exported template-based documents, select Keep Template Data Files. 4 If you want to update changes to previously exported files, select Extract Only Changed Files and click OK.
Applying or removing a template from an existing document Apply a template to an existing document When you apply a template to a document which contains existing content, Dreamweaver attempts to match the existing content to a region in the template. If you are applying a revised version of one of your existing templates, the names are likely to match. If you apply a template to a document that hasn’t had a template applied to it, there are no editable regions to compare and a mismatch occurs. Dreamweaver tracks these mismatches so you can select which region or regions to move the current page’s content to, or you can delete the mismatched content. You can apply a template to an existing document using the Assets panel or from the Document window. You can undo a template application if necessary. Important: When you apply a template to an existing document, the template replaces the document’s contents with the template’s boilerplate content. Always back up a page’s contents before applying a template to it.
Last updated 3/28/2012
392
USING DREAMWEAVER Creating and managing templates
Apply a template to an existing document using the Assets panel 1 Open the document you want to apply the template to. 2 In the Assets panel (Window > Assets), select the Templates category on the left side of the panel
.
3 Do one of the following:
• Drag the template you want to apply from the Assets panel to the Document window. • Select the template you want to apply, then click the Apply button at the bottom of the Assets panel. If content exists in the document that can’t be automatically assigned to a template region, the Inconsistent Region Names dialog box appears. 4 Select a destination for the content by using the Move Content to New Region menu to select one of the following:
• Select a region in the new template to move the existing content to. • Select Nowhere to remove the content from the document. 5 To move all unresolved content to the selected region, click Use For All. 6 Click OK to apply the template or click Cancel to cancel the application of the template to the document.
Important: When you apply a template to an existing document, the template replaces the document’s contents with the template’s boilerplate content. Always back up a page’s contents before applying a template to it.
Apply a template to an existing document from the Document window 1 Open the document you want to apply the template to. 2 Select Modify > Templates > Apply Template to Page.
The Select Template dialog box appears. 3 Choose a template from the list, then click Select.
If content exists in the document that can’t be automatically assigned to a template region, the Inconsistent Region Names dialog box appears. 4 Select a destination for the content by using the Move Content to New Region menu to select one of the following:
• Select a region in the new template to move the existing content to. • Select Nowhere to remove the content from the document. 5 To move all unresolved content to the selected region, click Use For All. 6 Click OK to apply the template or click Cancel to cancel the application of the template to the document.
Important: When you apply a template to an existing document, the template replaces the document’s contents with the template’s boilerplate content. Always back up a page’s contents before applying a template to it.
Undo the template changes ❖ Select Edit > Undo Apply Template.
The document reverts to its state before the template was applied.
Detach a document from a template To make changes to the locked regions of a document based on a template, you must detach the document from the template. When the document is detached, the entire document becomes editable.
Last updated 3/28/2012
393
USING DREAMWEAVER Creating and managing templates
Note: You cannot convert a template file (.dwt) to a normal file by simply resaving the template file as an HTML (.html) file. Doing so does not delete the template code that appears throughout the document. If you want to convert a template file to a normal file, you can save the document as a normal HTML file, but must then manually delete all of the template code in Code view. 1 Open the template-based document you want to detach. 2 Select Modify > Templates > Detach from Template.
The document is detached from the template and all template code is removed.
Editing content in a template-based document About editing content in template-based documents Dreamweaver templates specify regions that are locked (uneditable) and others that are editable for template-based documents. In pages based on templates, template users can edit content in editable regions only. You can easily identify and select editable regions to edit content. Template users cannot edit content in locked regions. Note: If you try to edit a locked region in a document based on a template when highlighting is turned off, the mouse pointer changes to indicate that you can’t click in a locked region. Template users can also modify properties and edit entries for a repeating region in template-based documents.
More Help topics “Create a page based on an existing template” on page 61 “About Dreamweaver templates” on page 366 “Select editable regions” on page 378
Modify template properties When template authors create parameters in a template, documents based on the template automatically inherit the parameters and their initial value settings. A template user can update editable tag attributes and other template parameters (such as optional region settings).
More Help topics “Template parameters” on page 368 “Using optional regions in templates” on page 381 “Defining editable tag attributes in templates” on page 383
Modify an editable tag attribute 1 Open the template-based document. 2 Select Modify > Template Properties.
The Template Properties dialog box opens, showing a list of available properties. The dialog box shows optional regions and editable tag attributes.
Last updated 3/28/2012
394
USING DREAMWEAVER Creating and managing templates
3 In the Name list, select the property.
The bottom area of the dialog box updates to show the selected property’s label and its assigned value. 4 In the field to the right of the property label, edit the value to modify the property in the document.
Note: The field name and updateable values are defined in the template. Attributes that do not appear in the Name list are not editable in the template-based document. 5 Select Allow Nested Templates To Control This if you want to pass the editable property along to a documents
based on the nested template.
Modify optional region template parameters 1 Open the template-based document. 2 Select Modify > Template Properties.
The Template Properties dialog box opens, showing a list of available properties. The dialog box shows optional regions and editable tag attributes. 3 In the Name list, select a property.
The dialog box updates to show the selected property’s label and its assigned value. 4 Select Show to display the optional region in the document, or deselect Show to hide the optional region.
Note: The field name and default setting are defined in the template,. 5 Select Allow Nested Templates To Control This if you want to pass the editable property along to a documents
based on the nested template.
Add, delete, and change the order of a repeating region entry Use repeating region controls to add, delete, or change the order of entries in template-based documents. When you add a repeating region entry, a copy of the entire repeating region is added. To update the content in the repeating regions, the original template must include an editable region in the repeating region.
More Help topics “Creating repeating regions in templates” on page 378
Add, delete, or change the order of a repeating region 1 Open the template-based document. 2 Place the insertion point in the repeating region to select it. 3 Do one of the following:
• Click the Plus (+) button to add a repeating region entry below the currently selected entry.
Last updated 3/28/2012
395
USING DREAMWEAVER Creating and managing templates
• Click the Minus (–) button to delete the selected repeating region entry. • Click the Down Arrow button to move the selected entry down one position. • Click the Up Arrow button to move the selected entry up one position. Note: Alternatively, you can select Modify > Template, then select one of the repeating entry options near the bottom of the context menu. You can use this menu to insert a new repeating entry or move the selected entry’s position.
Cut, copy, and delete entries 1 Open the template-based document. 2 Place the insertion point in the repeating region to select it. 3 Do one of the following:
• To cut a repeating entry, select Edit > Repeating Entries > Cut Repeating Entries. • To copy a repeating entry, select Edit > Repeating Entries > Copy Repeating Entries. • To remove a repeating entry, select Edit > Repeating Entries > Delete Repeating Entries. • To paste a repeating entry, select Edit > Paste. Note: Pasting inserts a new entry; it does not replace an existing entry.
Template syntax General syntax rules Dreamweaver uses HTML comment tags to specify regions in templates and template-based documents, so templatebased documents are still valid HTML files. When you insert a template object, template tags are inserted in the code. General syntax rules are as follows:
• Wherever a space appears, you can substitute any amount of white space (spaces, tabs, line breaks). The white space is mandatory except at the very beginning or end of a comment.
• Attributes can be given in any order. For example, in a TemplateParam, you can specify the type before the name. • Comment and attribute names are case sensitive. • All attributes must be in quotation marks. Single or double quotes can be used.
Template tags Dreamweaver uses the following template tags:
Last updated 3/28/2012
396
USING DREAMWEAVER Creating and managing templates
TemplateEndEditable --> TemplateParam name="..." type="..." value="..." --> TemplateBeginRepeat name="..." --> TemplateEndRepeat --> TemplateBeginIf cond="..." --> TemplateEndIf --> TemplateBeginPassthroughIf cond="..." --> TemplateEndPassthroughIf --> TemplateBeginMultipleIf --> TemplateEndMultipleIf --> TemplateBeginPassthroughMultipleIf --> TemplateEndPassthroughMultipleIf --> TemplateBeginIfClause cond="..." --> TemplateEndIfClause --> TemplateBeginPassthroughIfClause cond="..." --> TemplateEndPassthroughIfClause --> TemplateExpr expr="..." --> (equivalent to @@...@@) TemplatePassthroughExpr expr="..." --> TemplateInfo codeOutsideHTMLIsLocked="..." -->
Instance tags Dreamweaver uses the following instance tags: InstanceEnd --> InstanceBeginEditable name="..." --> InstanceEndEditable --> InstanceParam name="..." type="..." value="..." passthrough="..." --> InstanceBeginRepeat name="..." --> InstanceEndRepeat --> InstanceBeginRepeatEntry --> InstanceEndRepeatEntry -->
Check template syntax Dreamweaver checks the template syntax when you save a template, but you can manually check the template syntax prior to saving a template. For example, if you add a template parameter or expression in Code view, you can check that the code follows correct syntax. 1 Open the document you want to check in the Document window. 2 Select Modify > Templates > Check Template Syntax.
An error message appears if the syntax is badly formed. The error message describes the error and refers to the specific line in the code where the error exists.
More Help topics “Recognizing templates and template-based documents” on page 371 “Template expressions” on page 369
Last updated 3/28/2012
397
USING DREAMWEAVER Creating and managing templates
Setting authoring preferences for templates Customize code coloring preferences for a template Code color preferences control the text, background color, and style attributes of the text displayed in Code view. You can set your own color scheme so you can easily distinguish template regions when you view a document in Code view. 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Code Coloring from the category list on the left. 3 Select HTML from the Document Type list, then click the Edit Coloring Scheme button. 4 In the Styles For list select Template Tags. 5 Set color, background color, and style attributes for the Code view text by doing the following:
• If you want to change the text color, in the Text Color box type the hexadecimal value for the color you want to apply to the selected text, or use the color picker to select a color to apply to the text. Do the same in the Background field to add or change an existing background color for the selected text.
• If you want to add a style attribute to the selected code, click the B (bold), I (italic), or U (underline) buttons to set the desired format. 6 Click OK.
Note: If you want to make global changes, you can edit the source file that stores your preferences. On Windows XP, this is located at C:\Documents and Settings\%username%\Application Data\Adobe\Dreamweaver 9\Configuration\CodeColoring\Colors.xml. On Windows Vista, this is located at C:\Users\%username%\Application Data\Adobe\Dreamweaver 9\Configuration\CodeColoring\Colors.xml.
Set highlighting preferences for template regions You can use the Dreamweaver highlighting preferences to customize the highlight colors for the outlines around the editable and locked regions of a template in Design view. The editable region color appears in the template as well as in documents based on the template.
More Help topics “Recognizing template-based documents in Design view” on page 372 “Recognizing templates in Design view” on page 371
Change template highlight colors 1 Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh). 2 Select Highlighting from the category list on the left. 3 Click the Editable Regions, Nested Regions, or Locked Regions color box, then select a highlight color using the
color picker (or enter the hexadecimal value for the highlight color in the box). For information about using the color picker, see “Use the color picker” on page 205. 4 (Optional) Repeat the process for other template region types, as necessary. 5 Click the Show option to enable or disable displaying colors in the Document window.
Note: Nested Region does not have a Show option; its display is controlled by the Editable Region option. 6 Click OK.
Last updated 3/28/2012
398
USING DREAMWEAVER Creating and managing templates
View highlight colors in the Document window ❖ Select View > Visual Aids > Invisible Elements.
Highlight colors appear in the document window only when View > Visual Aids > Invisible Elements is enabled and the appropriate options are enabled in Highlighting preferences. Note: If invisible elements are showing but the highlight colors are not, select Edit > Preferences (Windows) or Dreamweaver > Preferences (Macintosh), and then select the Highlight category. Make sure that the Show option next to the appropriate highlight color is selected. Also make sure that the desired color is visible against the background color of your page.
Last updated 3/28/2012
399
Chapter 15: Building Spry pages visually The Spry framework is a JavaScript library that provides web designers with the ability to build web pages that offer richer experiences to their site visitors. With Spry, you can use HTML, CSS, and a minimal amount of JavaScript to incorporate XML data into your HTML documents, create widgets such as accordions and menu bars, and add different kinds of effects to various page elements. The Spry framework is designed so that markup is simple and easy to use for those users who have basic knowledge of HTML, CSS, and JavaScript. The Spry framework is meant primarily for users who are web design professionals or advanced nonprofessional web designers. It is not intended as a full web application framework for enterprise-level web development (though it can be used in conjunction with other enterprise-level pages).
About the Spry framework The Spry framework is a JavaScript library that provides web designers with the ability to build web pages that offer richer experiences to their site visitors. With Spry, you can use HTML, CSS, and a minimal amount of JavaScript to incorporate XML data into your HTML documents, create widgets such as accordions and menu bars, and add different kinds of effects to various page elements. The Spry framework is designed so that markup is simple and easy to use for those who have basic knowledge of HTML, CSS, and JavaScript. The Spry framework is meant primarily for users who are web design professionals or advanced nonprofessional web designers. It is not intended as a full web application framework for enterprise-level web development (though it can be used in conjunction with other enterprise-level pages). For more information on the Spry framework, see www.adobe.com/go/learn_dw_spryframework.
More Help topics Spry Developer Guide
Working with Spry widgets (general instructions) About Spry widgets A Spry widget is a page element that provides a richer user experience by enabling user interaction. A Spry widget comprises the following parts: Widget structure An HTML code block that defines the structural composition of the widget. Widget behavior JavaScript that controls how the widget responds to user-initiated events. Widget styling CSS that specifies the appearance of the widget.
The Spry framework supports a set of reusable widgets written in standard HTML, CSS, and JavaScript. You can easily insert these widgets—the code is HTML and CSS at its simplest—and then style the widget. The behaviors in the framework include functionality that lets users show or hide content on the page, change the appearance (such as color) of the page, interact with menu items, and much more.
Last updated 3/28/2012
400
USING DREAMWEAVER Building Spry pages visually
Each widget in the Spry framework is associated with unique CSS and JavaScript files. The CSS file contains everything necessary for styling the widget, and the JavaScript file gives the widget its functionality. When you insert a widget by using the Dreamweaver interface, Dreamweaver automatically links these files to your page so that your widget contains functionality and styling. The CSS and JavaScript files associated with a given widget are named after the widget, so it’s easy for you to know which files correspond to which widgets. (For example, the files associated with the Accordion widget are called SpryAccordion.css and SpryAccordion.js). When you insert a widget in a saved page, Dreamweaver creates a SpryAssets directory in your site, and saves the corresponding JavaScript and CSS files to that location.
More Help topics “Understanding Cascading Style Sheets” on page 116
Spry widgets resources and tutorials The following on-line resources provide more information on customizing Spry widgets. Spry widget samples Customizing Spry Menu Bars in Dreamweaver Spry Validation widgets (video tutorial)
Insert a Spry widget ❖ Select Insert > Spry, and select the widget to insert.
When you insert a widget, Dreamweaver automatically includes the necessary Spry JavaScript and CSS files in your site when you save the page. Note: You can also insert Spry widgets by using the Spry category in the Insert panel.
Select a Spry widget 1 Hold the mouse pointer over the widget until you see the widget’s blue tabbed outline. 2 Click the widget’s tab at the upper-left corner of the widget.
Edit a Spry widget ❖ Select the widget to edit and make your changes in the Property inspector (Window > Properties).
For details on making changes to specific widgets, see the appropriate sections for each widget.
Style a Spry widget ❖ Locate the appropriate CSS file for the widget in the SpryAssets folder of your site, and edit the CSS according to
your preferences. For details on styling specific widgets, see the appropriate customization sections for each widget. You can also format a Spry widget by editing styles in the CSS panel, just as you would for any other styled element on the page.
Last updated 3/28/2012
401
USING DREAMWEAVER Building Spry pages visually
Get more widgets There are many more web widgets available than the Spry widgets that install with Dreamweaver. The Adobe Exchangeprovides web widgets that have been developed by other creative professionals. ❖ Choose Browse for Web Widgets from the Extend Dreamweaver menu
in the Application bar.
For a video overview from the Dreamweaver engineering team about working with web widgets, see www.adobe.com/go/dw10widgets.
Change the default Spry assets folder When you insert a Spry widget, data set, or effect in a saved page, Dreamweaver creates a SpryAssets directory in your site, and saves the corresponding JavaScript and CSS files to that location. You can change the default location where Dreamweaver saves Spry assets if you prefer to save them somewhere else. 1 Select Sites > Manage Sites. 2 Select your site in the Manage Sites dialog box and click Edit. 3 In the Site Setup dialog box, expand Advanced Settings and select the Spry category. 4 Enter a path to the folder you want to use for Spry assets and click OK. You can also click the folder icon to browse
to a location.
More Help topics “Working with Dreamweaver sites” on page 34
Working with the Spry Accordion widget About the Accordion widget An Accordion widget is a set of collapsible panels that can store a large amount of content in a compact space. Site visitors hide or reveal the content stored in the accordion by clicking the tab of the panel. The panels of the accordion expand or contract accordingly as the visitor clicks different tabs. In an accordion, only one content panel is open and visible at a given time. The following example shows an Accordion widget, with the first panel expanded: A
C
B
A. Accordion panel tab B. Accordion panel content C. Accordion panel (open)
Last updated 3/28/2012
402
USING DREAMWEAVER Building Spry pages visually
The default HTML for the Accordion widget comprises an outer div tag that contains all of the panels, a div tag for each panel, and a header div and content div within the tag for each panel. An Accordion widget can contain any number of individual panels. The HTML for the Accordion widget also includes script tags in the head of the document and after the accordion’s HTML markup. For a more comprehensive explanation of how the Accordion widget works, including a full anatomy of the Accordion widget’s code, see www.adobe.com/go/learn_dw_spryaccordion. For a tutorial on working with the Accordion widget, see www.adobe.com/go/vid0167.
Insert and edit the Accordion widget Insert the Accordion widget ❖ Select Insert > Spry > Spry Accordion.
Note: You can also insert an Accordion widget by using the Spry category in the Insert panel.
Add a panel to an Accordion widget 1 Select an Accordion widget in the Document window. 2 Click the Panels Plus (+) button in the Property inspector (Window > Properties). 3 (Optional) Change the name of the panel by selecting the panel’s text in Design view and altering the text.
Delete a panel from an Accordion widget 1 Select an Accordion widget in the Document window. 2 In the Panels menu of the Property inspector (Window > Properties), select the name of the panel to delete, and
click the Minus (-) button.
Open a panel for editing ❖ Do one of the following:
• Move the mouse pointer over the tab of the panel to open it in Design view, and click the eye icon that appears at the right of the tab.
• Select an Accordion widget in the Document window, and then click the name of the panel to edit it in the Panels menu of the Property inspector (Window > Properties).
Change the order of panels 1 Select an Accordion widget in the Document window. 2 In the Property inspector (Window > Properties), select the name of the Accordion panel you want to move. 3 Click the up or down arrows to move the panel up or down.
Customize the Accordion widget Although the Property inspector enables you to make simple edits to an Accordion widget, it does not support customized styling tasks. You can alter the CSS rules for the Accordion widget and create an accordion that is styled to your liking. For a quick reference on changing the colors of the Accordion widget, see David Powers’s Quick guide to styling Spry tabbed panels, accordions, and collapsible panels.
Last updated 3/28/2012
403
USING DREAMWEAVER Building Spry pages visually
For a more advanced list of styling tasks, see www.adobe.com/go/learn_dw_spryaccordion_custom. All CSS rules in the following topics refer to the default rules located in the SpryAccordion.css file. Dreamweaver saves the SpryAccordion.css file in the SpryAssets folder of your site whenever you create a Spry Accordion widget. This file also contains commented information about various styles that apply to the widget, so you might find it helpful to consult the file as well. Although you can easily edit rules for the Accordion widget directly in the CSS file, you can also use the CSS Styles panel to edit the accordion’s CSS. The CSS Styles panel is helpful for locating the CSS classes assigned to different parts of the widget, especially if you use the panel’s Current mode.
More Help topics “The CSS Styles panel in Current mode” on page 121
Style Accordion widget text You can style the text of an Accordion widget by setting properties for the entire Accordion widget container, or by setting properties for the components of the widget individually. ❖ To change the text styling of an Accordion widget, use the following table to locate the appropriate CSS rule, and
then add your own text styling properties and values: Text to change
Relevant CSS rule
Example of properties and values to add
Text in the entire accordion (includes both tab and content panel)
.Accordion or .AccordionPanel
font: Arial; font-size:medium;
Text in accordion panel tabs only
.AccordionPanelTab
font: Arial; font-size:medium;
Text in accordion content panels only
.AccordionPanelContent
font: Arial; font-size:medium;
Change Accordion widget background colors ❖ To change the background colors of different parts of an Accordion widget, use the following table to locate the
appropriate CSS rule, and then add or change background color properties and values: Part of widget to change
Relevant CSS rule
Example of property and value to add or change
Background color of accordion panel tabs
.AccordionPanelTab
background-color: #CCCCCC; (This is the default value.)
Background color of accordion content panels
.AccordionPanelContent
background-color: #CCCCCC;
Background color of the open accordion panel
.AccordionPanelOpen .AccordionPanelTab
background-color: #EEEEEE; (This is the default value.)
Background color of panel tabs on hover
.AccordionPanelTabHover
color: #555555; (This is the default value.)
Background color of open panel tab on hover .AccordionPanelOpen
color: #555555; (This is the default value.)
.AccordionPanelTabHover
Constrain the width of an accordion By default, the Accordion widget expands to fill available space. You can constrain the width of an Accordion widget, however, by setting a width property for the accordion container. 1 Locate the .Accordion CSS rule by opening up the SpryAccordion.css file. This is the rule that defines properties
for the main container element of the Accordion widget.
Last updated 3/28/2012
404
USING DREAMWEAVER Building Spry pages visually
You can also locate the rule by selecting the Accordion widget, and looking in the CSS Styles panel (Window > CSS Styles). Make sure the panel is set to Current mode. 2 Add a width property and value to the rule, for example width: 300px;.
Working with the Spry Menu Bar widget About the Menu Bar widget A Menu Bar widget is a set of navigational menu buttons that display submenus when a site visitor hovers over one of the buttons. Menu Bars let you display a large amount of navigational information in a compact space, and also give visitors to the site a sense of what is available on the site without having to browse it extensively. Dreamweaver lets you insert two kinds of Menu Bar widgets: vertical and horizontal. The following example shows a horizontal Menu Bar widget, with the third menu item expanded:
A
B
Menu Bar widget (consists of , - , and tags) A. Menu item has submenu B. Submenu item has submenu
The HTML for the Menu Bar widget comprises an outer ul tag that contains an li tag for each of the top-level menu items. The top-level menu items (li tags) in turn contain ul and li tags that define submenus for each of the items, and submenus can likewise contain submenus. Top-level menus and submenus can contain as many submenu items as you like. For a more comprehensive explanation of how the Menu Bar widget works, including a full anatomy of the Menu Bar widget’s code, see www.adobe.com/go/learn_dw_sprymenubar. For a tutorial on creating a Spry Menu Bar, see www.adobe.com/go/vid0168.
More Help topics Spry Menu Bar tutorial
Insert and edit the Menu Bar widget Insert the Menu Bar widget 1 Select Insert > Spry > Spry Menu Bar. 2 Select Horizontal or Vertical, and click OK.
Note: You can also insert a Menu Bar widget using the Spry category of the Insert panel.
Last updated 3/28/2012
405
USING DREAMWEAVER Building Spry pages visually
Note: The Spry Menu Bar widget uses DHTML layers to display sections of HTML on top of other sections. If your page contains content created with Adobe Flash, this might cause a problem because SWF files are always displayed on top of all other DHTML layers, so the SWF file might be displayed on top of your submenus. The workaround for this situation is to change the parameters for the SWF file to use wmode="transparent". You can easily do this by selecting the SWF file in the Document window, and setting the wmode option in the Property inspector to transparent. For more information, see www.adobe.com/go/15523.
Add or delete menus and submenus Use the Property inspector (Window > Properties) to add or delete menu items to and from the Menu Bar widget. Add a main menu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector, click the plus button above the first column. 3 (Optional) Rename the new menu item by changing the default text in either the Document window or the Text
box of the Property inspector. Add a submenu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector, select the name of the main menu item to which you want to add the submenu. 3 Click the plus button above the second column. 4 (Optional) Rename the new submenu item by changing the default text in either the Document window or the Text
box of the Property inspector. To add a submenu to a submenu, select the name of the submenu item to which you want to add another submenu item, and click the plus button above the third column in the Property inspector. Note: Dreamweaver only supports two levels of submenus in Design view, but you can add as many submenus as you want in Code view. Delete a main menu or submenu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector, select the name of the main menu or submenu item you want to delete and click the
minus button.
Change the order of menu items 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector (Window > Properties), select the name of the menu item you want to reorder. 3 Click the up or down arrows to move the menu item up or down.
Change the text of a menu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector (Window > Properties) select the name of the menu item whose text you want to change. 3 Make your changes in the Text box.
Last updated 3/28/2012
406
USING DREAMWEAVER Building Spry pages visually
Link a menu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector (Window > Properties) select the name of the menu item to which you want to apply a link. 3 Type the link in the Link text box, or click the folder icon to browse to a file.
Create a tool tip for a menu item 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector (Window > Properties) select the name of the menu item for which you want to create a
tool tip. 3 Type the text for the tool tip in the Title text box.
Assign a target attribute for a menu item The target attribute specifies where to open a linked page. For example, you can assign a target attribute to a menu item so that the linked page opens in a new browser window when the site visitor clicks the link. If you are using framesets, you can also specify the name of a frame where you want the linked page to open. 1 Select a Menu Bar widget in the Document window. 2 In the Property inspector (Window > Properties), select the name of the menu item to which you want to assign a
target attribute. 3 Enter one of the four attributes in the Target box: _blank Opens the linked page in a new browser window. _self Loads the linked page in the same browser window. This is the default option. If the page is in a frame or
frameset, the page loads within that frame. _parent Loads the linked document in the immediate frameset parent of the document. _top Loads the linked page in the topmost window of a frameset.
Turn off styles You can disable the styling of a Menu Bar widget so that you can better see the HTML structure of the widget in Design view. For example, when you disable styles, menu bar items are displayed in a bulleted list on the page, rather than as the styled items of the menu bar. 1 Select a Menu Bar widget in the Document window. 2 Click the Turn Styles Off button in the Property Inspector (Window > Properties).
Change the orientation of a Menu Bar widget You can change the orientation of a Menu Bar widget from horizontal to vertical, and vice versa. All you need to do is alter the HTML code for the menu bar and make sure you have the correct CSS file in your SpryAssets folder. The following example changes a horizontal Menu Bar widget to a vertical Menu Bar widget. 1 In Dreamweaver, open the page that contains a horizontal Menu Bar widget. 2 Insert a vertical Menu Bar widget (Insert > Spry > Spry Menu Bar) and save the page. This step ensures that the
correct CSS file for a vertical menu bar is included in your site.
Last updated 3/28/2012
407
USING DREAMWEAVER Building Spry pages visually
Note: If your site already has a vertical Menu Bar widget somewhere else, you don’t need to insert a new one. You can simply attach the SpryMenuBarVertical.css file to the page instead by clicking the Attach Style Sheet button in the CSS Styles panel (Windows > CSS Styles). 3 Delete the vertical Menu Bar. 4 In Code view (View > Code), locate the MenuBarHorizontal class and change it to MenuBarVertical. The
MenuBarHorizontal class is defined in the container ul tag for the menu bar ( |