Creating Snippets

Dreamweaver comes with a lot of snippets, many of which you may have no use for. No problem—it’s simple to create snippets of your own. Here’s how:

  1. Create and select the code you wish to turn into a snippet.

    You could, for instance, select table in Design view, or select the opening and closing <table> tags (as well all code between them) in Code view.

    If you make a snippet out of code that isn’t visible in Design view, such as a JavaScript program or content that appears in the <head> of the page, you’ll need to switch into Code view first and then select the code.

  2. Click the New Snippet button on the Snippets tab (Figure 17-1).

    The Snippet window appears (Figure 17-2), displaying the code you selected in the Insert field.

    The Snippet window lets you create reusable chunks of HTML called snippets. For snippets that wrap around a currently selected object on the page—for example, a snippet that adds a link to any selected text or graphic—you put code in the two insert boxes. The code that appears before the selected object goes in the top box, and code after the object appears in the bottom box.

    Figure 17-2.  The Snippet window lets you create reusable chunks of HTML called snippets. For snippets that wrap around a currently selected object on the page—for example, a snippet that adds a link to any selected text or graphic—you put code in the two insert boxes. The code that appears before the selected object goes in the top box, and code after the object appears in the bottom box.

    Tip

    If you skip step 1, and just click the New Snippet button, you can either type the code or paste a previously copied selection into the Insert box (see step 6).

  3. Title the snippet.

    The name you type in the Name field appears in the Snippet tab. Make sure to ...

Get Dreamweaver MX: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.