Chapter 6. Getting Started with Dreamweaver

Getting Started with Dreamweaver
  • Setting up a new or existing site

  • Defining a Web site in Dreamweaver

  • Creating new Web pages

  • Setting links in Dreamweaver

  • Changing page-wide settings with page properties

  • Adding meta tags for search engines

  • Adding code from YouTube, Google, and other sites in Dreamweaver

The high-end features in Dreamweaver make it the preferred choice for professional Web designers, but its easy-to-use graphical interface makes it popular among novices and hobbyists as well. This book is designed to help you create a Web site as quickly as possible by providing you with templates for a variety of common Web sites and instructions for how to customize those templates in Dreamweaver. If you're eager to get started, feel free to jump ahead to Chapter 7, 8, or 9, where you find instructions for using Dreamweaver to customize the ready-to-use templates that come with this book.

Before you do, though, I suggest that you at least skim through this chapter so that you have some familiarity with the most important features in Dreamweaver, how I've used Dreamweaver's advanced template features to help you create sites quickly, and how you can edit those templates with this great Web design program. This chapter is designed to introduce you to Dreamweaver and to show you how to do some the most common tasks with this popular design program, such as creating new pages, inserting images, setting links, and defining CSS styles.

Tip

At the beginning of this chapter, you find detailed instructions for one of the most important features in Dreamweaver: the Site Definition dialog box. Defining a site in Dreamweaver is important whether you use one of the templates featured later in this book or create your own, custom design using the instructions in the rest of this chapter. Before you work on any Web site in Dreamweaver, you should start with the site-definition process.

Note

In my effort to keep things simple in this book, I cover only a small portion of the features in this complex program. You can read lots more about Dreamweaver in my bookDreamweaver CS4 For Dummies (Wiley).

Setting Up a New or Existing Site

As a general rule, when you create a Web site, you first create all the pages on your computer's hard drive, where you can preview your pages in a Web browser and test the site before it's visible on the Internet. Then, when the site is ready, you transfer the files to your Web server, a computer with a permanent connection to the Internet that uses special software to communicate with Web browsers, such as Internet Explorer, Safari, Chrome, and Firefox.

Because all the files you work with on your hard drive must be in the same relative location on the Web server, you need to store all your site's resources in one folder on your hard drive and identify that folder as the local root folder in Dreamweaver.

As you progress through the site-definition process in the following task, you can create a new folder on your hard drive and designate it as your local root folder, or you can identify an existing folder if you're updating or redesigning a site. The location where you save the local root folder on your hard drive doesn't matter, as long as you identify it as the main folder for your Web site in Dreamweaver. Note: If you move the local root folder, you have to go through the site setup process again so that Dreamweaver knows where to find it.

When you're ready to publish a completed site, you can transfer it to your Web server by using the Dreamweaver built-in File Transfer Protocol (or FTP) features. You find detailed instructions for testing and publishing a Web site in Chapter 10.

Tip

Throughout this book, I use Adobe Dreamweaver CS4, but most of the features I cover have not changed much in the last few versions, so even if you're using another version of Dreamweaver, such as 8 or CS3, you should be able to follow most of these instructions with few, if any, adjustments. Just be aware that some panels and other options may be in different locations in earlier versions.

Defining a Web Site in Dreamweaver

If the site-definition process seems a little confusing at first, don't worry; it's a quick, relatively painless process, and you have to do it only once for each site. Just trust me — don't skip this preliminary step.

Whether you're creating a new site or working on an existing site, the following steps walk you through the process of defining a local root folder for your Web site.

Stuff You Need to Know
  1. Choose Site

    Stuff You Need to Know
  2. Click the Advanced tab. Note: If you prefer, you can use the basic wizard that steps you through the setup process, but I find it faster and easier to view all the options at once from the Advanced tab.

    Stuff You Need to Know
  3. In the Category box on the left, make sure that the Local Info category is selected so that you can specify the location of the folder on your local hard drive. This category should be open by default when you click the Advanced tab. (You find instructions for setting up the options in the Remote category so that you can publish your site to a Web server in Chapter 10.)

    Stuff You Need to Know
  4. In the Site Name text box, type a name for your site. You can call your site whatever you like; this name is used only to help you keep track of your sites. Many people work on more than one site in Dreamweaver, and this feature enables you to keep track of them by name. The name you enter here appears in the drop-down list in the Files panel and in the Manage Sites dialog box. You use this list to select the site you want to work on when you open Dreamweaver. In this example, I named the new site Pamela's Pet Services.

    Stuff You Need to Know
  5. Click the Browse icon next to the Local Root Folder text box to locate the folder on your hard drive that you want to serve as the main folder for all files in your Web site. (Hint: The Browse icon in Dreamweaver always looks like a small, yellow file folder and is usually located at the right side of a text field.) If you're setting up a new site, create a new folder on your hard drive, using the Create New Folder icon in the Choose Local Folder dialog, and then select that folder as the local root folder. If you're setting up an existing Web site, select the folder that contains the files for that site to designate it as the Local Root Folder.

    Stuff You Need to Know
  6. Click the Browse icon next to the Default Images folder field and then select the images folder in an existing Web site. If you're creating a new site, create a new folder inside your local root folder, name it images, and select it. Although you don't have to identify an images folder, it has some advantages. For example, if you ever insert an image that isn't located in your local root folder, Dreamweaver copies it into the images folder you identify during the site setup process. If you create an images folder, Dreamweaver copies images into the main folder. (You can also store images in other folders within your local root folder.)

    Stuff You Need to Know
  7. For the Links Relative To radio buttons, leave the Document option selected unless you know that you want your links to be set up relative to the root level of your site. This setting controls how the path is set in links. If you're working on a site with other developers and you're not sure, check with your colleagues. If you're working alone on your own site, Links Relative to Document is the simplest option and should already be selected because it's the default option in Dreamweaver.

    Stuff You Need to Know
  8. In the HTTP Address text box, type the URL of your Web site. The HTTP address is the URL, or Web address, that your site will have when it's published on a Web server (see Chapter 2). If you don't yet know the Web address for your site or you don't plan to publish it on a Web server, you can leave this box blank. If you do fill it in, include http:// at the beginning and / at the end.

    Stuff You Need to Know
  9. Select the Use Case-Sensitive Link Checking check box. Unless you know for sure that you don't have to worry about the case of your filenames, selecting this box makes Dreamweaver ensure that the case matches for all your site's links (which many Web hosting services require).

    Stuff You Need to Know
  10. Select the Enable Cache option. Dreamweaver creates a local cache of your site to quickly reference the location of files in your site. The local cache speeds up many site management features of the program and takes only a few seconds to create.

    Stuff You Need to Know
  11. Click OK to close the Site Definition dialog box and save your settings. If the folder you selected as your local site folder already contains files or subfolders, they're automatically cached and any files or folders in your site are displayed in the Files panel. In this example, because I'm creating a new site, only the images subfolder is displayed. If you haven't checked the Enable Cache option, a message box appears, asking whether you want to create a cache for the site. Doing so is good practice because it helps Dreamweaver work more efficiently.

    Stuff You Need to Know

Tip

You can make changes and additions to a site by choosing Site

Stuff You Need to Know
  1. If you work on more than one site in Dreamweaver, be sure to define each site the first time you work on it. After that, you can easily switch among defined sites by selecting the one you want to work on in the Files panel. You can define as many sites as you like in Dreamweaver. To load a different site into the Files panel, click the drop-down arrow next to the site name and choose the name of the site you want to display. In this figure, you can see that I'm opening the site named Pamela's Pet Services by selecting it from a long list of defined sites.

    Stuff You Need to Know

Creating New Pages in Dreamweaver

In this task, I show you how easy it is to create a new page in Dreamweaver and add and format text. Whether you're creating a simple design or a complex one, it's almost always easier to start with one of the prestyled Cascading Style Sheet (CSS) layouts included in Dreamweaver. You can use Dreamweaver's collection of layouts to create a variety of one, two, and three-column designs using CSS, and as you see in the steps that follow, you can customize these layouts in many ways. Before you rush off to take a look at all the layouts included with Dreamweaver, let me warn you that they're not much to look at when you first open them. They're intentionally designed with a basic, gray color scheme. Fortunately, though, color styles are some of the easiest to alter in CSS.

If you're new to CSS, altering one of these layouts may seem confusing at first, but it's certainly easier than starting a page layout from scratch yourself. In this chapter, I focus on a simple, one-column design, a great way to practice the basics before you get into the steps you'll need to follow to customize the more complex layouts included in the templates later in this book. Before you begin creating new pages, make sure that you complete the site setup process covered in the preceding task in this chapter.

  1. To create a new page, choose File

    Stuff You Need to Know
    Stuff You Need to Know

Tip

A fixed layout is generally an easier option to start with, but "liquid" designs have advantages because they're more flexible. You can find a longer description of the layout types in the Dreamweaver Help files, but essentially here are the options. Liquid layouts are designed to expand and contract, depending upon the size of the browser window; fixed layouts are centered within the browser and set to a width of 780 pixels (easy to change); elastic layouts use the EMs measurement to adapt to different text sizes and other variations in display; and hybrid layouts use a mix of options.

  1. When HTML is selected in the New Document dialog box, a list of CSS layouts appears in the Layout Column. In the close-up view of this dialog box, shown in this figure, you can see that I selected a design that creates a one-column fixed layout with a header and footer. The rest of the options in this dialog are optional, so keep things simple and just click the Create button.

    Stuff You Need to Know
  2. Get into the (excellent) habit of saving a new page as soon as it's created. Choose File

    Stuff You Need to Know
    Stuff You Need to Know
  3. Adding or editing text in a new page in Dreamweaver is relatively simple. For example, if you want to change the text at the top of the page, just select the word Header and type in the text you want to use to replace it. In this case, I entered Pamela's Pet Services. Because I selected the Header first, the font, style, and size of the text in the original layout are preserved. Replace the subheadings and main text in the page in the same way.

    Stuff You Need to Know
  4. All Dreamweaver layouts include a collection of corresponding styles. As a result, to edit many of the elements, such as the background color of the header area, you must edit the corresponding style. First, open the CSS Styles panel (if it's not already open) by choosing Window

    Inserting text from another program
    Inserting text from another program
  5. To change the color or other style options for the header, double-click the style named .oneColFixCtrHdr #header to open it in the CSS Rule Definition dialog box. Click to select the Background category, and use the color palette to change the background color. Choose the Type category to access font, size, and other text options. Click Apply to see how the settings look, and then click OK to save them and close the dialog box.

    Inserting text from another program
  6. To change the width of the one-column layout, you need to edit the Div tag that surrounds all the content on the page. By following the common practice of using Div tags to "contain" elements on a page and styles, to describe how they should be displayed, Dreamweaver includes a Div identified as container in every layout. The container controls the overall width of the design area; to change the width of your design, you need to change the corresponding style. To do so, double-click the style named .oneColFixCtrHdr #container to open it in the CSS Rule Definition dialog box. (The Div is the foundation of the box model, which I explain in Chapter 4.)

    Inserting text from another program

Tip

This is an advanced tip. If you don't like the compound styles used in Dreamweaver layouts, you can simplify them. Dreamweaver includes a body class for each of these layouts and includes it in the name of each style. In this case, the body class is oneColFixCtrHdr. You can remove the body class by deleting .oneColFixCtrHdr from the front of each style name, but if you do so, you must also delete it from the body tag in the HTML code. To do so, first click the Split View button at the top of the workspace to open the HTML code, and then search for the body tag and delete class="oneColFixCtrHdr". Although removing the class style is optional, it simplifies the rest of the style names by making them all shorter, which many designers find easier when working with style sheets. To save you from having to find the body tag in the HTML code, I leave the longer style names the way Dreamweaver creates them in this task.

  1. In the CSS Rule Definition dialog, choose Box from the Category list (left) and then use the width field to change the width as desired. In this case, I'm changing the width from 780 pixels to 980 by replacing the number in the Width field. Limiting the width of your page to 780 pixels is good practice if you want your page to display well in an 800 × 600 resolution monitor, but most Web designers today design for a monitor resolution of 1024 × 786 and a width of 980 is well suited to that size, leaving just enough room for scrollbars and other elements of the browser that take up space on the screen. Click Apply to preview your changes, and then click OK to save your changes and close the dialog box.

    Inserting text from another program
  2. You can also change the font or color of any or all text on a page by changing the corresponding styles. If you aren't familiar with HTML, you may not guess that to change the font style for the entire page, you need to alter the Body style. That's because the <body> tag controls page-wide settings, like font face and link styles. You can use multiple fonts on a page by changing the font style for a specific section of text, but to change the default font for the entire page, double-click Body in the CSS Styles panel, choose the Type category and use the Font-family drop-down list to select a font collection.

    Inserting text from another program

Tip

If the body tag isn't already defined with a style, you might find it easier to use the Page Properties dialog box, described in the section, "Changing Page-Wide Settings with Page Properties," later in this chapter. For more information on font collections and using XHTML and CSS together, see Chapter 4.

Inserting Images in Dreamweaver

You can add images in the JPEG, PNG, or GIF format to your pages in Dreamweaver. In Chapter 5, you discover how to optimize images for the Web. In this task, you learn how to insert image into a Web page in Dreamweaver.

Stuff You Need to Know
  1. For many designs, such as the one featured in this task for Pamela's Pet Services, you may want to use a graphic instead of text in the Header. First, simply delete the text in the Header area, and then choose Insert

    Stuff You Need to Know

Tip

Alternate text, which is displayed if an image isn't visible, provides a description of the image for visitors who are visually impaired and use special browsers that "read" Web pages aloud. Including key words in Alt text can also make your page more search engine friendly.

  1. Although I changed the width of the layout to match the width of my banner (in the previous task), the banner didn't line up properly when I inserted it into the header. That's because the header is styled for text and includes padding to better position the text away from the sides of the layout. To make an image, such as this banner fit in the header properly, you need to remove the extra space. First, click the style named .oneColFixCtrHdr #header in the CSS Styles panel. Then expand the Styles panel to display the Properties for the #header style and delete everything in the padding field by selecting it and pressing the Delete key.

    Stuff You Need to Know
  2. Even after deleting the padding, you're still likely to have extra space at the top and bottom of the banner; this space is caused by the H1 tag attributes that make the header text large and bold. If you deleted the H1 tag when you deleted the text, you won't have this problem, but it's easy to leave the H1 tag behind. Here's a good way to remove any unwanted HTML formatting. First, click to place your cursor in the Header area. (It doesn't matter whether you select the image). Then in the tag selector at the bottom of the workspace, right-click the H1 tag and choose Remove Tag.

    Stuff You Need to Know
  3. To insert an image in an area of the page where you have text, click to place your cursor where you want the image to appear and then choose Insert

    Stuff You Need to Know
    Stuff You Need to Know
  4. To align an image to the right or left and wrap the text around it, your best option is to use a CSS style. In all the templates included with this book, and in many of the CSS Layouts included with Dreamweaver, you'll find styles with the name fltrt (or float-right) for aligning images to the right, and fltlft (or float-left), for aligning images to the left. To use these styles, first click to select the image. Then, in the Property Inspector, click the Class drop-down list and choose the alignment style you want to use. In this example, I selected fltlft.

    Stuff You Need to Know
  5. The alignment styles, such as float-right and float-left, include a margin setting of 8 pixels (px) to create a small margin between an image and any text that wraps around it when it's aligned to the left or right of a page. You can change the margin settings to increase or decrease this space by clicking to select the style in the CSS Styles panel, and then changing the number of pixels in the Properties pane. Alternatively, you can double-click the style name to open the CSS Rule definition dialog and change the margin settings in the Box category.

    Stuff You Need to Know

Tip

You can adjust the margins and padding around images, Div tags, and other elements to control spacing and positioning. The simplest way to understand padding and margins is to remember this statement: Padding adds space to the inside of an element, and margins add space to the outside. The same statement is true whether the element is a Div tag, an image, a table cell, or anything else. If you want more space around a photo, for example, add margin space. If you want a gap between the edge of a Div tag and its contents, add padding. Here's an advanced tip: When you add padding, you increase the overall size of the element. For example, a photo that's 200 px wide and has 10 px of padding on each side expands to fill 220 px of space in the design.

Setting Links to Other Pages in Your Site

Dreamweaver is truly a dream when it comes to setting links. The most important thing to keep in mind is that a link is essentially an address (a URL) that tells a visitor's browser which page to open when the visitor clicks the text or image containing the link.

If the page you want to link to is within your Web site, you can create a relative link, which includes a path describing how to get from the current page to the linked page. A relative link doesn't need to include the domain name of the site — just the instructions for a browser to move from one page within your site to another. (If you want to link to a page outside your site, see the next section, "Linking to Another Web Site.")

When you link from one page to another page in your Web site, the most important thing to remember is to save your pages in your site's root folder (as described in "Defining a Web Site in Dreamweaver," earlier in this chapter) before you start setting links. Here's how to create a link from one page to another within a Web site:

  1. In Dreamweaver, open the page where you want to create a link. Select the text or image that you want to serve as the link (the text or image that a user clicks to trigger the link). Click and drag to highlight text, or click once to select an image. In this example, I select the text Learn more about our boarding services, and I want to link it to a page named boarding.html located in a folder named services. Note that all these files and folders are located inside the local root folder that I defined for this site in Dreamweaver.

    Stuff You Need to Know
  2. To set the link, click the Link icon on the Common Insert panel to open the Hyperlink dialog box. (Alternatively, you can choose Insert

    Stuff You Need to Know
    Stuff You Need to Know
  3. In the Hyperlink dialog box, click the Browse icon (the yellow file folder) to the right of the Link field. In the Select File dialog box that appears, navigate on your hard drive to the page to which you want to link your image or text. Click to select the filename of the page, and then click OK (in Windows) or Choose (on a Mac). The rest of the settings in this dialog box are optional. (See sidebar on "Targeting how links open".)

    Stuff You Need to Know
  4. The link is automatically set, and the dialog box closes. If you create a link by using text, as I do in this example, the text changes to reflect the style for a link. By default, Active links appear underlined and in dark blue. To test your links, you must view the page in a Web browser. Choose File

    Stuff You Need to Know
    Stuff You Need to Know

Tip

If you haven't already saved your page, a message box opens, explaining that you can create a relative link only after you save the page. Always save the page you're working on before you set links.

Linking to Another Web Site

Linking to a page on another Web site — called an external link — is even easier than linking to an internal link. All you need is the URL of the page to which you want to link, and you're most of the way there.

To create an external link, follow these steps:

Stuff You Need to Know
  1. In Dreamweaver, open the page from which you want to link and click to select an image, or click and drag to highlight the text that you want to act as a link. You can also click to select any image on the page to serve as the link. In this example, I selected the text visit www.petfinder.com., at the bottom of the page.

    Stuff You Need to Know
  2. In the Link text box in the Property Inspector, type the URL of the page you want your text or image to link to, and then press Enter (in Windows) or Return (on the Mac). You can also copy and paste a URL from the address bar in a Web browser, which is an excellent way to ensure that you don't enter the address incorrectly. You must always use the full URL, including the http:// part, when you create an external link in HTML. Otherwise, the browser can't find the correct external site address.

  3. The link is set automatically, and the text changes to indicate that it's an active link. To test a link to another Web site, you must view your page in a browser and be connected to the Internet. Choose File

    Stuff You Need to Know

Setting a Link to an E-Mail Address

Another common link option directs site visitors to an e-mail address. Visitors can send you messages easily with e-mail links. I always recommend that you invite visitors to contact you because they can point out mistakes in your site and give you valuable feedback about how you can further develop your site. Adding contact information also lends credibility to a Web site because it shows that you're accessible and open to being contacted.

Setting a link to an e-mail address is just as easy as setting a link to another Web page. All you need to know is the e-mail address you want to link to and which text or image you want to use when you set the link.

  1. To create an e-mail link, select the text that you want to serve as the link.

    Stuff You Need to Know
  2. With the text selected, click the Email Link icon on the Common Insert panel. Alternatively, you can choose Insert

    Stuff You Need to Know
    Stuff You Need to Know

Tip

When visitors to your Web site click an e-mail link, the visitor's computer system automatically launches the default e-mail program and creates a blank e-mail message to the specified e-mail address. This is a cool trick, but it can be disconcerting to users who don't expect it to happen, and it doesn't work if they don't have an e-mail program on their computer. That's why I always try to let users know when I use an e-mail link. For example, rather than just link the words Contact Janine, I link the words Email Janine. Even better, I often link the actual e-mail address.

  1. In the Email Link dialog box that opens, enter the e-mail address in the E-Mail field and click OK. The dialog box closes and the text automatically changes to the style for an active link.

    Stuff You Need to Know
  2. The Email Link dialog box works only with text. If you want to use an image as an e-mail link, you must select the image and then enter the e-mail address, preceded by mailto: in the Link field in the Property Inspector. In this example, the image is selected, and the e-mail link has been created by entering mailto:.

    Stuff You Need to Know

Warning

When you create an e-mail link on a Web page to be displayed on the public Internet, you open yourself to spammers, some of whom use automated programs to "lift" e-mail addresses off Web pages. That's why many sites don't include e-mail links, but instead use text such as "Send e-mail to Janine at jcwarner dot-com." You can also use a form to get around this potential problem. By setting up a form with a script that delivers the form's contents to an e-mail address, you can shield your e-mail address from spammers while still making it easy for visitors to your site to send comments. A relatively new alternative is offered by the Web site AddressMunger.com, which you can use to create a special script that shields your e-mail address from spammers. You can find more information in Chapter 15 about AddressMunger.com and other services that you can use to enhance your Web site.

Changing Page-Wide Settings with Page Properties

You can change many individual elements on a page in the Property Inspector, but if you want to make changes that affect the entire page, such as changing the background color of the entire page or changing the way links and text are formatted, you can use the Page Properties dialog box. Although you can apply global settings, such as text size and color, in the Page Properties dialog box, you can override those settings with other formatting options in specific instances. For example, you can set all text to the Helvetica font in the page properties and then change the font for an individual headline to Verdana via the Font field in the Property Inspector. To change the font settings, background and text colors, and link colors for an entire page, follow these steps:

  1. Choose Modify

    Stuff You Need to Know
    Stuff You Need to Know
  2. In the Size drop-down list, specify the font size you want for the text on your page. (In this example, I selected 100%, but you can choose from a variety of size settings.) Click the Text Color swatch box to reveal the color palette. Choose any color you want for the text color on the page. The color you select fills the color swatch box but doesn't change the text color on the page until you click Apply or OK.

    Stuff You Need to Know

Tip

When you change the background, text, or link colors, make sure that the colors look good together and that your text is still readable. As a general rule, go for high contrast pairings: light text is best displayed on a dark background, and dark text is best displayed on a light background.

  1. Click the Background Color swatch box and choose a color if you want to fill the background of the page with a solid color. If you want to insert a graphic into the background of your page, as I did here, click the Browse button next to the Background Image box, and in the Select Image Source dialog box that appears, select an image and click OK to return to the Page Properties dialog box. When you insert a background image, it automatically repeats (or tiles) across and down the page unless you choose the no-repeat option from the Repeat drop-down list or use CSS to further define the display.

    Stuff You Need to Know
  2. Use the margin options at the bottom of the dialog box to change the left, right, top, or bottom margins of your page. Entering 0 in all four fields removes the default margin settings, which automatically add margin space at the top and left side of a Web page, enabling you to create designs whose edges begin flush with the edge of a browser. Most professional designers prefer to set the margins to 0 and then use other CSS settings to control the positioning of the design within a browser window.

    Stuff You Need to Know
  3. To alter the display of links on a page, first select the Links (CSS) category from the left side of the Page Properties dialog box. Specify the font face and size you want for the links on your page. If you don't specify a font, links appear in the same font and size that are specified for the text in your document.

    Stuff You Need to Know

Note

Although you can vary the link styles to suit the design of your site, it's good practice to use the same link styles throughout your site so that your visitors can easily identify links.

  1. To the right of the Link Font drop-down list, click the B or I icon if you want all links on your page to appear in bold or italic, respectively. Specify a color for any link option (or all link options) by clicking the color palette and selecting a color for each of the link states separately. The color you select is applied to links on your page based on the link state. All four link states can be displayed in the same or different colors:

    • Link Color: This option controls the color in which a link appears when it's first displayed on a page.

    • Visited Links: This option controls the color of links that a visitor has already clicked, or visited.

    • Rollover Links: A link changes to this color when a user rolls the cursor over the link (also known as hovering).

    • Active Links: A link changes to this color briefly while a user is actively clicking it.

    Stuff You Need to Know
  2. In the Underline Style drop-down list, specify whether you want links underlined. By default, all links on a Web page appear underlined in a browser, but many designers find the underline distracting and prefer to turn it off by selecting Never Underline. You can also choose Show Underline Only on Rollover to make the underline appear when a user moves a cursor over a link. Hide Underline on Rollover causes the underline to disappear when a user moves a cursor over a link.

    Stuff You Need to Know
  3. As you alter the different settings, you can click the Apply button to see how the changes appear on your page. After you specify all the settings, click OK to finish and close the Page Properties dialog box.

    Stuff You Need to Know

Defining New Styles in Dreamweaver

Whether you create a new, blank page in Dreamweaver or start with one of the Dreamweaver CSS layouts, as described in an earlier task in this chapter, you can create your own styles to format text, images, and other elements in your pages.

As you move through the steps to create a new style in Dreamweaver, you might be surprised by the number of options in the numerous panels and dialog boxes available for creating CSS. As you explore the possibilities, remember that you can leave attributes unspecified if you don't want to use them and that you can always go back and edit styles after you create them.

To define a new style, either create a new document or open an existing Web page in Dreamweaver and follow these steps:

  1. Choose Format

    Stuff You Need to Know
    Stuff You Need to Know
  2. In the New CSS Rule dialog box, choose the type of CSS selector you want to create from the Selector Type drop-down menu. (If you need a refresher on the four selector options and choosing selector types, see Chapter 4.) In this example, I'm creating a class style that I will use to format the captions for my images. In the Selector Name field, type a name. Because class styles must begin with a period (.), I named this style .imagecaption.

    Stuff You Need to Know
  3. In the Rule Definition area at the bottom of the New CSS Rule dialog box, select where you want to define your new style. Choose This Document Only from the drop-down menu to create an internal style sheet. In this example, I'm adding my new style to an external style sheet that's already attached to my page (design.css). To create an external style sheet, click to select the name of the style sheet, or choose New Style Sheet File to create a new style sheet file as you create the style. If you choose to create a new style sheet, enter a name in the Save Style Sheet File As dialog box and then click Save to continue. Usually, you want to add a style to an external style sheet; see Chapter 4 for details about internal versus external style sheets.

    Stuff You Need to Know
  4. In the CSS Rule Definition dialog box, choose a category on the left. For this example, I chose the Type category to specify font options for this style because I want the font to be different from the main page font. As you can see in this figure, I chose the Georgia, Times New Roman, Times, serif font collection; set the Font size to Small; and set the Font weight to Bold. (See Chapter 4 for more information about font collections.) Click OK to save the style and close the dialog box.

    Stuff You Need to Know
  5. The new style appears at the bottom of the CSS Styles panel. You can change the order of styles by clicking to select a style name and dragging it to another position in the panel.

    Stuff You Need to Know
  6. To apply a new class style, like the one I created in this task, select a section of text in a Web page and then use the Class drop-down list to select and apply the style. For more information on how to apply other kinds of styles, see Chapter 4.

    Stuff You Need to Know

Creating and Using Templates

After all the time you spend creating a page design in Dreamweaver, you might be pleased to know about templates. When you save a file as a Dreamweaver Web Template, it becomes available from the New File dialog box, which makes it easy to use to create new pages quickly. But the greatest time-saving benefit of Dreamweaver's Web Templates becomes evident when you want to make changes to a design after you use it to create numerous pages because you can use templates to make global updates across many pages at once.

Most of the templates included with this book use the Dreamweaver Web Template features. Reading through this task not only shows you how to create your own templates but also helps you better understand how to use and edit the templates that you can download to use with this book. To find the templates, just go to www.DigitalFamily.com/diy.

In this task, you learn how to save any page as a template, use the template to create new pages, and then edit the template to make global updates to those pages.

  1. To create a new template, choose File

    Stuff You Need to Know
    Stuff You Need to Know
  2. In the Save As Template dialog box, make sure that the site you're working on is displayed in the Site field. (This should happen automatically if you completed the site definition process; if you haven't, make sure to do so by following the steps in the first task in this chapter.) You can name the template anything you like as long as you don't use spaces or punctuation. When you're prompted by the Update Links dialog box, choose Yes to preserve any links to pages or images in the file.

    Stuff You Need to Know
  3. When you create a Web Template, Dreamweaver automatically adds the .dwt extension. In this case, my file is named services.dwt. As you can see in the Files panel shown in this figure, Dreamweaver automatically stores the new template in a folder named Templates. If you don't already have a Templates folder in your local root folder, Dreamweaver creates one for you when you save your first template. If Dreamweaver prompts you to update links as you save the page as a template, click Yes.

    Stuff You Need to Know

Tip

Although the Dreamweaver layouts are designed to display CSS and other formatting options according to contemporary standards, not all Web browsers support CSS the same way, so it's always wise to test your designs in a variety of Web browsers before you publish them. And here's a tip: Internet Explorer and Safari do not display Dreamweaver Web Templates, but Firefox does. Thus, if you're working on a template and want to preview your work as you go along, choose File

Stuff You Need to Know
Stuff You Need to Know
  1. Before you use your template to create new pages, you need to create editable regions in the template: areas of the template that can be edited in new pages created from the template. You create editable regions where you want to be able to add unique content to a new page created from the template, such as the photos and stories you will want to use in the main part of each page. To create an editable region, first select a container, such as the mainContent div, that contains the text and image in the middle of this page. To select the mainContent div, I place my cursor in the content and then clicked the mainContent tag in the tag selector at the bottom of the page.

Note

Any area that's not an editable region can only be edited in the template itself, and any edits you make to a part of the page that isn't designated as editable will automatically be updated on all the pages created from the page. For example, I wouldn't make the banner at the top of this page an editable region because I want to use the same banner at the top of every page in this site.

  1. With a container selected, such as the mainContent div, choose Insert

    Stuff You Need to Know
    Stuff You Need to Know
  2. In the New Editable Region dialog box that opens, give the region a name (no spaces or special characters!), and then click OK. I enter the name Main in this example. If you don't have visual aids turned off, Dreamweaver will distinguish the editable region by surrounding it with a blue line and including a small tab at the top with the name you gave the region. Repeat Steps 4, 5, and 6, selecting different containers in turn to create additional editable regions.

    Stuff You Need to Know
  3. After you define all editable regions, choose File

    Stuff You Need to Know
    Stuff You Need to Know
  4. Always save a new page before you start editing it by choosing File

    Stuff You Need to Know
    Stuff You Need to Know
  5. At any time, you can go back to the template to make changes to any area of the template that isn't an editable region, and those changes will automatically be applied to any pages created from the template. In this example, I included copyright information in the footer of the page. Because it's not an editable region, I can now change the year from 2009 to 2010, and the footer will automatically be updated on every page in the site created from the template.

    Stuff You Need to Know
  6. To save your changes and update any pages created from the template at the same time, choose File

    Stuff You Need to Know
    Stuff You Need to Know

Adding Meta Tags for Search Engines

If you've heard of meta tags, you probably correctly associate them with search engines. Although meta tags are used for a variety of purposes, the most common is to provide special text that doesn't appear in the body of your page but is read by crawlers, bots, and other programs that scour the Web, reading the code behind Web pages and cataloging and ranking those pages for Bing, Google, and a long list of other search-related sites.

Some search engines read meta tags for keywords and descriptions. The keyword meta tag enables site designers to specify a list of keywords that match the content on their Web sites when someone types the same keywords into a search engine. The meta description tag is designed to let you include a written description of your Web site, and search engines often display its content as the brief description that appears in search results pages, so including a meta description in all your pages is definitely worthwhile. Follow these steps to fill in the meta description tag:

  1. Open the page where you want to add a meta description. You can use meta descriptions on any page, or all pages, on your Web site. Choose Insert

    Stuff You Need to Know
    Stuff You Need to Know
  2. To view or edit the Meta description after you create it, choose either the Split or Code view option by clicking the corresponding button at the top of the workspace. In this example, I selected Split so that both Code view and Design view are visible. To edit the meta description, locate it in the HTML code, and then you can delete, change, or add text as you would in Design view. The description text you enter is inserted into the Head area at the top of the page in the HTML code. Meta content doesn't appear in the body of the page.

    Stuff You Need to Know

Tip

If you want to add keywords, repeat Steps 1 and 2 and choose Insert

Stuff You Need to Know

Inserting Code into a Web Page in Dreamweaver

Many of the services featured in this book, including Google AdSense, PayPal Buttons, and Google Analytics, require that you add a snippet of HTML code or JavaScript to your Web pages.

In many cases, you need to add the same code to one or more pages in a site. In the example featured in this task, I'm adding the code needed for Google Analytics, which measures traffic to a Web site and needs to be included at the bottom of every page on a site. In this case, the most efficient way to add the code is to insert it into the template page. Adding code to a template will add the code to every page created from the template simultaneously.

When you open Dreamweaver to add your code, leave your Web browser open so that it displays the page where you copied the code, in case you want to make changes or need to copy the code again. You can easily switch between two programs on your computer by pressing Alt+Tab (Windows) or

Stuff You Need to Know
  1. The easiest way to add code to a page in Dreamweaver is click the Split View button in the upper-left corner of the workspace to display the code behind the page in the top part of the workspace. The advantage of using Split view is that you can see Design and Code views at the same time. Here's a tip: When you're working on code that adds a visible element to your page, click any element in Design view, such as the Copyright information in the footer at the bottom of this page, and Dreamweaver automatically highlights the corresponding code so that you can find your place more easily.

    Stuff You Need to Know

Tip

One of the most confusing aspects of adding code to your site is that sometimes you see it in the design and other times you don't. For example, when you add Google Analytics code to a page in Dreamweaver, no visible change takes place on the page in Design view because the analytics code is only used to measure traffic to the page with nothing visible to your visitors. However, some kinds of code, such as Google AdSense which displays ads in a Web page, can be viewed, but only when you preview a page in a Web browser. Another point that trips up new Web designers is that, for the code to take effect, you'll need to upload the page to a Web server so that Google can find the AdSense code and begin tracking your traffic. You find instructions for publishing your pages in Dreamweaver and more about how to use Google Analytics in Chapter 10.

Stuff You Need to Know
  1. Find the exact place where you want to add the code. Google Analytics should be added just above the </body> tag at the very end of a page. Click to place the cursor in the code; then choose Edit

    Stuff You Need to Know

Note

The code you copy from a site like Google may include a script or other code that isn't in basic HTML. This issue shouldn't matter as long as you copy the code exactly as Google (or any other Web site) instructs you to and you paste all the code into the HTML in your Web page. For example, if the code begins with a <script> tag, it should include a closing </script> tag.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset