Attaching a behavior to text

Attaching a behavior to text

You can’t attach a behavior to plain text. Tags like p and span don’t generate events in browsers, so there’s no way to trigger an action from those tags.

However, you can attach a behavior to a link. Therefore, to attach a behavior to text, the easiest approach is to add a null link (that doesn’t point to anything) to the text, then attach the behavior to the link. Note that if you do this, your text will appear as a link. You can change the link color and remove the underlining if you really don’t want it to look like a link, but site visitors may then be unaware that there’s a reason to click that text.

To attach a behavior to the selected text:

  1. In the Property inspector, enter javascript:; in the Link text box. Be sure to include both the colon and the semicolon.
  2. With the text still selected, open the Behaviors panel (Window > Behaviors).
  3. Select an action from the Actions pop-up menu, enter parameters for the action, and select an event to trigger the action. For detailed information, see Applying a behavior.

To change the appearance of linked text to make it look like it isn’t a link:

  1. Open the Document window’s Code view by selecting View > Code.
  2. Find the link.
  3. In the link’s a href tag, insert this attribute: style="text-decoration:none; color:black".

    This attribute setting disables underlining and sets the color of the text to black. (Of course, if the surrounding text is a different color, use that color instead of black.)

    Note that this attribute is an inline CSS style. An inline style applied to a single link overrides other CSS styles that apply to that link, but has no effect outside of that link. To change the appearance of linked text everywhere on a page or across your entire site, use CSS styles to create a new style for links. For detailed information, see Inserting and Formatting Text.

Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Inserting and Formatting Text
Adding Audio, Video, and Interactive Elements
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly