Snippets Basics

Snippets aren’t fancy or complex, but they sure save time. A snippet is simply a chunk of code you store away and then plunk into your web pages as necessary. The can be as simple as boilerplate legal text, or as complex as HTML, CSS, or JavaScript code (or code from any other programming language you encounter). For example, say you always use the same table design to list product specifications in your company’s catalog. Each time you want to create a similar table, you could go through all the same steps to build it—or you could turn that table into a snippet, and then, with a simple double-click, add it to page after page of your site.

You keep these code chunks in the Snippets panel (see Figure 19-1), and you summon them in a couple of ways:

  • Choose Window→Snippets.

  • Windows people can press Shift-F9. (There’s no Mac keyboard shortcut for opening the Snippets panel, but you can create your own if you want, as described on Keyboard Shortcuts.)

Once open, the Snippets panel appears grouped with the Files and Assets panels. Above and beyond Dreamweaver’s preinstalled snippets, you can quickly build a collection of your own.

Get Dreamweaver CS5: 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.