Using Snippets

Snippets come in two varieties: those that are simple blocks of code, and those that wrap around a currently selected element in a document. For example, in the Snippets panel’s Text folder, you’ll find a snippet called Service Mark. Adding this snippet to a page instantly inserts the code <sup>sm</sup>, creating a superscript service mark (sm) symbol.

But on occasion, you’ll want to wrap code around something you’ve already typed. You may, for example, want to add an HTML comment to your page (a message that won’t appear in web browsers, but that helps you or other web designers decipher the page). The “Comment, multi-line” snippet (in the Comments folder of the Snippets panel) helps you quickly add such a note. It wraps whatever you select with opening (<!--) and closing HTML comment markers (-->). Adding an HTML comment is as easy as typing the comment in your page, selecting it, and then double-clicking this snippet. This may sound a lot like the Apply Comment button in the Coding toolbar described in Figure 7-7, but the cool thing about this snippet is that it works in Design view, too, not just in Code view.

Note

Unfortunately, unless the snippet’s description (which you find in the Snippet Panel’s Description column) specifies that the snippet wraps, you can’t tell whether it will or not. You either have to try out the snippet or open it in Editing mode to see. (And while you have the snippet open, you can add a note to its description indicating its ability, ...

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