Using Graphics on Your Dreamweaver PagesOnce you have some graphics and have saved them in the appropriate formathere, JPEG or GIFactually getting them onto your page is fairly easy. What you may find difficult is getting your images positioned where you want them. Thankfully, Dreamweaver has a few tricks up its sleeve to help you, as you'll soon see. But let's start with something easy: setting a graphic for your page's background. Using a Graphic as a Page BackgroundMany sites on the web use either a colored or graphical background on their pages. This makes the site look a little more interesting, and also plays a part in a site's overall design and branding Keep a high contrast between your background and your page text, to keep your page legible. In designing your page's background, keep a few things in mind. If you're going to use a color, don't choose anything too bright. You don't want your visitor's head to explode, so choose a color that's easy on the eyes. If you decide to use a graphical background, be very cautious. Background graphics can easily render a page's text illegiblea major frustration for web surfers. Keep a high contrast between your background and your page text, and you shouldn't have a problem. :This page uses a subtle background graphic: a brushed metal look. Even though the page may look like it has one massive image in the background, effects like this can usually be created with a single, tiny graphic. Here's the sort of background image to avoid. Here's how to set your page's background:
Controlling Your Page Background with CSSNow that you have a background on your page, you may wish to make further modifications. The background for your page is always controlled by HTML's <body> tag. So when you set a background through the Page Properties dialog box, Dreamweaver creates a redefine88 tag for you. By making changes to the rules that govern the <body> tag in CSS, you can control how the image tiles, whether the background image scrolls with the page, and a few other neat options not available in the Page Properties dialog box. To change your page background via CSS, follow these steps: Now let's start thinking a little grander here. In Chapter 8, you saw how to work with external style sheets. Wouldn't it be great if you could control the background of all the pages in your site from a single style? Well, you can! In your external style sheet, create a new rule for the <body> tag; then set the appropriate options in the Background category, just as we did here. Once that's done, link all your pages to the external style sheet, and you're ready to go. Also, you can specify a background for just a single style rather than for the entire page. For example, you can set a yellow background behind all of the Heading 1 elements on your page. If you've already set a background color for your page, both the style's background and the page background will appear. If you have some CSS styles kicking around from Chapter 8, try setting options in their Background category. This will result in a background appearing behind only the space that the style occupies on the page. CSS's parlor tricks are endless! Placing Images on Your PageNow you're ready to insert images on your page. Before you begin, make sure that all the graphics that you want to use have been copied to your site folder; otherwise, you'll have serious problems when you go to upload your pages to your remote site. We'll talk about possible problems that may arise in a bit, but first, let's get droppin' graphics onto your page. Before placing images on your page, make sure that all your graphics have been copied to your site folder. Here's how to insert an image on your page:
| ||||||||||
4. | The Image Tag Accessibility Attributes dialog box appears. Enter any accessibility information you want; then click OK. The image appears on your page where you originally placed your insertion point. Now, depending on the size of the image and where you placed your insertion point, your image may not appear as expected. We'll talk about how to adjust your image's placement shortly. |
Always remember that when you insert a graphic, the graphic is not embedded in your page. Instead, Dreamweaver creates a reference to the source graphic file. This is fundamental. If you make a change to the original image source file (the one sitting in your site's local folder), the graphic will be updated automatically on any page where it's used, because those pages are simply referencing the source file. This is similar to the way Cascading Style Sheets works.
When you insert a graphic into your web page, the graphic is not embedded in your page. Instead, Dreamweaver creates a reference to the source graphic file.
If you change the name of your graphic in Dreamweaver's File panel, a dialog box will appear asking you to update all the references to the graphic. Click Update, and Dreamweaver will handle all your image references for you.
Double-clicking a graphic in the Assets panel opens the image in your external graphics editor.
Be careful if you monkey with any of your site files outside of Dreamweaver. If you were to quit Dreamweaver and then open your site folder on your hard drive and change file names, move files around, or delete files, then the next time you launch Dreamweaver, all the links to your graphics would be lost.
Imminent Doom
If you change a graphic's name in the Files panel and don't click Update, the path between the web page and your graphic will be brokenmeaning that your image will not appear on your page. |
If you rename or move a graphic outside of Dreamweaver, the connection between your web page and the image will be broken. To avoid seeing the missing image icon, keep a clean nose and use the Files panel in Dreamweaver to move and rename your images.
So be careful with your graphic references. If you need to rename or delete graphics in your site, make sure to do it through the Files panel, so Dreamweaver can help you manage all references to your graphics.
Because the images in your web pages are really just references, you can also easily swap one graphic for another, replacing the old graphic with a new one.
Geek's Delight
By default, Dreamweaver creates a link to an image like this: img/Astronaut.jpg. But rather than using that type of path, you could type something like this in the Property Inspector's Src field: [http://www.tentonbooks.com/img/test.jpg]. This would link you directly to an image file, even if it's being used in another web site. This is called hot linking. It's okay to do this with your own sites, but it's a no-no to hot link to other people's images because it eats up their site's bandwidth. |
Here's how to replace a graphic:
1. | On your web page, double-click the graphic that you want to replace. You can also select the graphic on your page and then, in the Property Inspector, click the folder beside the Src field. |
2. | In the Select Image Source dialog box that opens, navigate to the new image that you want; then click OK (Windows) or Select (Mac). The old image is replaced with the new image. |
Finally, because all graphics are referenced, all your imagesevery last one of themwill have to be uploaded when you publish your site to the web. Remember back in Chapter 4, you saw that Dreamweaver will upload your entire site in one shot for you, so you don't have to upload your files one at a time. But make sure to double-check that everything uploads. If you miss a graphic, it won't be displayed on your site. Instead, your site's visitors will see an empty image placeholder, which looks really amateurish.
A missing graphic on a live web page is a major design faux pas. It's really important to upload all your graphics to your remote site and test every page in your site to make sure that all your images are loading correctly.