Chapter 19. Snippets and Libraries

OK, so you finished the design for your company’s new website. It looks great and your boss is ecstatic. But you’ve really only just begun. You have to build hundreds of pages before you launch the site. And once the site’s online, you need to make endless updates to keep it fresh and inviting.

That’s where Dreamweaver’s Snippets and Library features come in, streamlining the sometimes tedious work of building and updating site pages.

As you create more and more web pages (and more and more websites), you may find yourself crafting the same page elements over and over again. Many of your pages may share common elements that always stay the same: a copyright notice, a navigation bar, or a logo, for example. And you may find yourself frequently using complex components, such as a pull-down menu that lists all the countries you ship products to or a particular design for photos and their captions.

Recreating the same components time after time is tiresome and—thanks to Dreamweaver—unnecessary. Dreamweaver provides two subtly different tools for reusing common page elements: Snippets and Library items.

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. Snippets 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 ...

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