Using Snippets

Snippets come in two varieties: those that are a simple block of code, and those that wrap around your current selection 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 a web browser, but that helps you or other web designers decipher the page). The “Comment, multi-line” snippet (in the Comments folder) can help you quickly add such a note. It wraps whatever you select with opening (<!--) and closing HTML comments (-->). 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 inFigure 11-7, but the cool thing about this snippet is that it works in Design view, too, not just 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 the snippet in Editing mode to find out. (And while you have the snippet open, you can add a note to its description indicating its ability, or inability, to wrap.) ...

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.