|< Day Day Up >|
17.2 Using Snippets
Snippets come in two varieties: those that are a simple block of code and those that wrap around the current selection in the document. For example, in the Text folder of the Snippets tab, 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 may want to wrap code around something you've already typed. You may want to add an HTML comment to your page (a message that won't appear in a Web browser, but that you can use for helpful notes to yourself or other Web designers). The "Comment, multi-line" snippet (in the Comments folder) can help you add such comments quickly. It wraps whatever you've selected with opening (<!--) and closing HTML comments (-->). Adding an HTML comment is as easy as typing the comment, selecting it, and then inserting this snippet.
Unfortunately, unless the snippet's description (visible in the Snippet Panel's Description column) speci- fies that the snippet wraps, there's no way to tell whether a snippet is intended to wrap around a selection. You either have to try the snippet, or open the snippet in editing mode (see Section 17.3.1) to find out. (While you've got the snippet open, you can add a note to its description indicating its ability, or inability, to wrap.)
To add a snippet to a Web page, click in the document where you want the item to go, or select the object you wish to wrap with a snippet. Then do one of the following:
Snippets simply dump their contents into a document; Dreamweaver doesn't step in to make sure that you're adding the code correctly. Unless you're careful梐nd have some knowledge of HTML梱ou might end up adding snippets that make your Web page unviewable. (For advice on how to avoid such pitfalls, see the box in Section 17.4.)
The Snippets tab on the Code panel contains reusable
chunks of code梥nippets梬hich you can organize in
folders. After selecting a snippet from the list, a preview
appears in the preview pane.
|< Day Day Up >|