1. Trang chủ
  2. » Công Nghệ Thông Tin

wiley adobe dreamweaver cs5 bible phần 4 ppsx

135 313 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 135
Dung lượng 3,3 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

If you choose an image imported from Fireworks, when you first launch Optimize Image — either by clicking the Edit Image Settings button on the Property inspector or choosing the Optimiz

Trang 1

12 In the Property inspector, choose imageLeft from the Style drop-down list.

13 You can also simply drag images directly onto the page from the Files panel In the panel, expand

the images folder and drag under_contruction_02.jpg to the left of the third heading, Room

to grow.

14 If the Image Tag Accessibility Attributes dialog box appears, enter Under construction in the

Alternative Text field.

15 In the Property inspector, choose imageRight from the Style drop-down list.

Each of the methods demonstrated works well; use the one you’re most comfortable with when

adding graphics to a page

Optimizing and altering images

It’s the rare graphic that integrates into the Web page design unaltered Digital photographs often

need to be cropped and almost always need to be reduced — either in dimensions, file size, or

both Other images may need to be sharpened to achieve an immediate effect or lightened to fit

better into the page palette Dreamweaver provides several pathways to the perfect Web image:

Image editing within Dreamweaver:

L Without even leaving Dreamweaver, you can

crop, resample, sharpen, and alter brightness and contrast of any selected GIF or JPG graphic You don’t even have to have a graphics editor such as Adobe Photoshop or

continued

Trang 2

Graphic optimization within Dreamweaver:

L For more sophisticated image tions — without full-scale editing — choose Edit Image Settings A dialog box opens within Dreamweaver where you can compare different outcomes before committing to a scaling, resampling, or conversion operation You explore this option a little later in the

opera-“Employing the Optimize Image Settings Command” section

Round-trip editing from Dreamweaver to your graphics editor:

com-plex image modifications, use an external graphics editor such as Adobe Photoshop or Fireworks Dreamweaver sends files to the editor of your choosing

Cross-Reference

If you’ve inserted a photoshop psD file as your image, changes made in photoshop are automatically updated

in Dreamweaver For more details, see Chapter 24 n

The route you take depends on the depth of the modifications required A key difference among

these three different types of operations (one that you’ll want to factor into your image-editing

decision) is that the tools within Dreamweaver work on the actual graphic exported for Web

use After the page containing the image is saved, changes cannot be reversed If Fireworks is

your graphics editor, both the Optimize and Graphics Editor options can utilize the source files

and create the exported file The main advantage to using source graphics is that you have much

greater control and flexibility; many types of changes can be done and undone as many times

as needed The primary disadvantage is that not all Web designers have the option to alter the

source graphics

Regardless of which route you choose, you’ll find it’s easy to get there Dreamweaver has

central-ized access to all of the graphic tools in the most appropriate place — the Image Property

inspec-tor (see Figure 8-4)

Figure 8-4

Dreamweaver includes a range of image-editing tools right on the Image Property inspector

Edit Image Settings Edit

Crop Resample Brightness and Contrast

Sharpen

Begin your tour of Dreamweaver image altering options by looking at the built-in tools first

Trang 3

Cropping graphics

If you want to show only part of a photograph in the real world, you’d use a pair of scissors to

crop off what you don’t want With digital graphic tools, no scissors are needed Images are cropped

for two main reasons: to focus attention on a particular area or to reduce file size Often these

reasons work hand-in-glove because a cropped image is always smaller than the original in both

physical dimensions and file size

Dreamweaver’s cropping tool is both powerful and easy to use When you choose to crop a graphic,

a shaded border appears within the graphic The edges of the border can be dragged to determine

how the image should be trimmed The region outside the border is darkened, but you can still

see the full image so you can be sure a vital part of the graphic is not inadvertently cut

To crop an image, follow these steps:

1. Select the image you want to crop

2. In the Property inspector, click the Crop button

3. Dreamweaver displays an alert to warn you that the cropping operation changes the

selected image; click OK to clear the dialog A shaded border appears within the selected image (see Figure 8-5)

4. Drag the selection handles that appear in the middle of each side to crop the image in a

single direction; the cursor changes to a two-headed arrow when in the correct position

to crop a side

5. To move the entire cropping area, drag the highlighted rectangle into the desired

posi-tion; you can move the cropping area when the cursor is shown as a four-headed arrow

Figure 8-5

A repositionable, shaded border appears so that you can crop your images onscreen

Trang 4

6. To cancel the cropping operation, click anywhere outside the graphic.

7. Complete the crop by double-clicking within the image

After cropping, you can reverse the effect by choosing Edit ➪ Undo — but only until the page is

saved or sent to an external graphics editor

Resampling after resizing

Finding the perfect size for an image is often a matter of trial and error: It’s important that a

graphic work together with the entire page layout for maximum effect Dreamweaver makes it

easy to resize an image — just drag the sizing handles to the desired location (You can find a

complete discussion of Dreamweaver’s resizing features later in this chapter in the “Adjusting

height and width” section.) However, resizing an image in Dreamweaver is not the same as

rescaling it in a graphics program; Dreamweaver merely draws the image to fit the chosen

dimen-sions, much as a browser would It doesn’t actually re-create the graphic

To get the cleanest, clearest representation of a resized graphic, you must resample the image

Resampling refers to the process of adding or subtracting pixels when the image is resized If a

graphic’s dimensions are increased, pixels are formulaically added; make the image small and

pixels are removed according to a similar algorithm Dreamweaver includes a resampling option,

which becomes available when an image is resized, either by dragging the sizing handles or

changing the values in the Width and Height fields of the Property inspector

Resampling in Dreamweaver is a one-click affair — no parameters are set Just choose the resized

image and click the Resample button on the Property inspector As with the other built-in tools,

an alert informs you that the graphics file is being changed (unless you’ve selected the Don’t

Show Me This Message Again option)

How the image resamples really depends on the image itself and the difference between the

origi-nal image size and the new size Sometimes, resampling in either direction results in satisfactory

images (see Figure 8-6) Typically, I find that small differences work far better than large ones;

if you’re making a major change in image size, it’s often better to use a dedicated graphics editor

such as Fireworks or Photoshop

Trang 5

Affecting brightness and contrast

Digital photography has opened the floodgates for posting images on the Web Unfortunately,

not all images look as good as they might If you want to make the graphic lighter or darker or

perhaps use a little more contrast, Dreamweaver has just the tool you need The Brightness and

Contrast command offers independent control over the two interlinked aspects of an image Best

of all, the Brightness/Contrast dialog box offers a Preview option, as shown in Figure 8-7, so that

you can see the changes to the image in real time

Figure 8-7

Preview the changes when using the Brightness and Contrast control to make sure you’re getting the effect

you want

To alter the brightness and/or contrast of an image, follow these steps:

1. Select the image you want to modify

2. Click the Brightness and Contrast button on the Property inspector Dreamweaver

dis-plays the Brightness/Contrast dialog box

3. Make sure the Preview box is selected to see the changes applied as you move the

controls

4. Drag the Brightness slider to the left or right Dragging the slider to the left lowers the

brightness; dragging it to the right increases brightness Alternatively, you can enter a value directly in the Brightness field Acceptable values are from –100 to 100, with 0 being the default

5. Move the Contrast slider to the right to increase the contrast or to the left to decrease it

Alternatively, you can enter a value between –100 and 100 in the Contrast field

6. When you’re finished, click OK

Although Brightness and Contrast is most frequently associated with photographic JPEG images,

it can also be used for GIFs However, be careful if your GIF has a transparent area; altering the

brightness and/or contrast too much could make the transparent area visible

Sharpening graphic lines

In Web applications, fuzzy logic is generally sought after, but fuzzy photos are not You can clear

up blurry images with Dreamweaver’s Sharpen command found on the Property inspector

Trang 6

The Sharpen command examines the edges found within a graphic and programmatically

increases the contrast of the related pixels Flat areas of color are left unaffected The Sharpen

dialog (see Figure 8-8) offers a sliding scale from 0 to 10 where 10 represents the maximum

amount of sharpening available in one operation As with the Brightness/Contrast dialog, you

can select the preview option

Figure 8-8

Bring your images into focus with Dreamweaver’s Sharpen feature

Note

If you’re using Fireworks and need more sharpening power than Dreamweaver offers, try applying the

Unsharp Mask in Fireworks Despite the name, this filter is terrific for sharpening blurry images and, when

applied as a Live Filter from the property inspector, is totally reversible in a Fireworks native pnG file n

Employing the Optimize Image command

Not all images are Web-ready — especially those that are used in other media such as printing

To provide the best online experience, Web graphics must balance appearance and file size You

want your images to look as good as possible at the lowest possible file size because a small file

is quicker to download The process of achieving the balance between the image quality and file

size is called optimizing You can optimize your images without leaving Dreamweaver by

run-ning the Optimize command

The Optimize command actually opens a dialog box that originated in Fireworks as the Image

Preview dialog Exporting from Fireworks is a major step and a lot of options are at your

finger-tips during the process Here’s just a little of what’s possible:

Switch formats from GIF to JPEG or vice versa Other formats include animated GIF

Trang 7

Crop a figure visually.

Get the best Web image possible at the lowest file size through the Image Preview dialog box, opened by

the Optimize Image command

If you choose an image imported from Fireworks, when you first launch Optimize Image — either by

clicking the Edit Image Settings button on the Property inspector or choosing the Optimize Image

command from the Commands menu — Dreamweaver presents a dialog that asks whether you’d

like to edit the source PNG file or the current file When you choose the source file, Dreamweaver

automatically re-exports the file and stores the changes when you’re done

Trang 8

For a full explanation of all that’s possible through the Optimize Image command, see Chapter 24 n

Editing images

Although Dreamweaver includes some tools for cropping, sharpening, and otherwise revising

images in your Web pages, it is not a full-featured graphics editor Certain tasks — such as slicing

a larger graphic into sections or adding text to an image — are beyond Dreamweaver’s scope You

can, however, set up your graphics editor of choice to work hand-in-hand with Dreamweaver

Specify your primary graphics editor for each type of graphic in the File Types/Editors category

of Preferences

ChangingGraphics

Dreamweaver’s built-in graphics functions are perfect for low-level quick fixes when an image needs

to be cropped or resampled In this Dreamweaver Technique, you have an opportunity to adjust one

picture in a number of ways

1 Open the images_start.htm file worked on in the last Dreamweaver Technique.

2 Select the second image on the page, next to the “Big house, big garage” heading As you see, this

image has a few problems in the outer part of the picture; with Dreamweaver, you can crop those

right out of view.

3 On the Property inspector, click Crop.

continued

Trang 9

4 Dreamweaver alerts you that taking this action will affect the selected image; click OK to continue.

5 Move the cropping handles on the top and left to exclude the white patches; move the cropping

handles on the right and bottom to the outer edge of the images.

6 When you’ve moved the cropping handles to the correct position, double-click in the center of the

image to confirm your changes The image is still a bit too big; you can use the built-in Rescale tool

to make a simple adjustment.

7 Select the image again and drag the lower-right sizing handle inward to reduce the image size; press

the Shift key while dragging to constrain the width/height ratio.

8 Stop resizing the image when the Width attribute in the Property inspector is 215 pixels While the

image appears to be resized, it now needs to be resampled so that it is actually reduced in file size.

9 On the Property inspector, click Resample You’ll notice that the image file size shown in the

Property inspector is reduced from 14K to 10K.

10 Dreamweaver again alerts you that taking this action will affect the selected image; click OK to

continue.

11 When you’re done, save your page.

Although you will always need to work with a graphics editor such as Photoshop or Fireworks for

major image modifications, Dreamweaver does a great job on last-minute fixes all by itself

After you’ve picked an image editor, clicking the Edit button in the Property inspector opens

the application with the current image After you’ve made the modifications, just save the file in

your image editor and switch back to Dreamweaver The new, modified graphic has already been

included in the Web page If you change the image size, you can click the Reset Size button on

the Image Property inspector to see your changes

Cross-Reference

If you are using either photoshop or Fireworks as your image editor, here is some good news: Dreamweaver

works very closely with both photoshop and Fireworks, enabling you to create and modify images with

round-trip ease Find out more in Chapter 24 n

Modifying image attributes

When you insert an image in Dreamweaver, the image tag, <img>, is inserted into your HTML

code The <img> tag takes several attributes; the most commonly used can be entered through

the Property inspector Code for a basic image looks like the following:

<img src=”images/myimage.gif” width=”172” height=”180”>

Dreamweaver centralizes all its image functions in the Property inspector The Image Property

continued

Trang 10

Dreamweaver automatically inserts the image filename in the Src text box (as the src attribute)

To replace a currently selected image with another, click the folder icon next to the Src text box,

or double-click the image itself Either sequence opens the Select Image Source dialog box When

you’ve selected the file, Dreamweaver automatically refreshes the page and corrects the code

Figure 8-10

The Image Property inspector gives you total control over the HTML code for every image

Filename Thumbnail

File size

Src folder icon

If the Image Property inspector is open when you insert your image, you can begin to modify the

image attributes immediately

Naming your image

When you first insert a graphic into the page, the Image Property inspector displays a blank text

box next to the thumbnail and file size Fill in this box with a unique name for the image, to be

used in JavaScript and other applications

Adjusting height and width

The width and height attributes are important because browsers build Web pages faster when

they know the size and shape of the included images Dreamweaver reads these attributes when

the image is first loaded The width and height values are initially expressed in pixels and are

automatically inserted as attributes in the HTML code

Browsers can dynamically resize an image if its height and width on the page are different from

the original image’s dimensions For example, you can load your primary logo on the home

page and then use a smaller version of it on subsequent pages by inserting the same image with

reduced height and width values Because you’re only loading the image once and the browser is

resizing it, download time for your Web page can be significantly reduced

Note

resizing an image just means changing its appearance onscreen; the file size stays exactly the same To

reduce a file size for an image, you need to scale it down in a graphics program such as Fireworks or, once

you’ve resized it in Dreamweaver, click resample in the property inspector n

Trang 11

To resize an image in Dreamweaver, select the image and type the desired number of pixels in the

Property inspector’s H (height) and W (width) fields With Dreamweaver, you can also visually

resize your graphics by using the click-and-drag method A selected image has three sizing handles

located on the right, bottom, and lower-right corners of its bounding box Click any of these

handles and drag it out to a new location — when you release the mouse, Dreamweaver resizes

the image To maintain the current height/width aspect ratio, hold down the Shift key after

start-ing to drag the corner sizstart-ing handle

If you alter either the height or the width of an image, Dreamweaver displays the Property

inspector values in bold in their respective fields You can restore an image’s default

measure-ments by clicking the H or the W independently — or you can click the Reset Size button to

restore both values

Caution

If you elect to enable your viewer’s browser to resize your image on-the-fly using the height/width values you

specify, keep in mind that the browser is not a graphics-editing program and that its resizing algorithms are

not sophisticated View your resized images through several browsers to ensure acceptable results n

Using margins

You can offset images with surrounding whitespace by using the margin attributes The amount

of whitespace around your image can be designated both vertically and horizontally through the

vspace and hspace attributes, respectively These margin values are entered, in pixels, into

the V Space and H Space text boxes in the Image Property inspector

The V Space value adds the same amount of whitespace along the top and bottom of your image;

the H Space value increases the whitespace on the left and right sides of the image These values

must be positive; HTML doesn’t allow images to overlap text or other images (outside of AP

ele-ments) Unlike in page layout, negative whitespace does not exist

Note

The hspace and vspace attributes are deprecated in hTML 4.0 This means that, although the attributes

are currently still supported, another preferred method achieves the same effect in newer browsers In most

cases, the margins should be implemented using Cascading style sheets, described in Chapter 6 n

Adding image descriptions

It’s easy for Web designers to get caught up in the visual design of their Web pages; after all,

designers can devote hours to creating a single graphic or to perfectly positioning a graphic on

the page relative to other information Remember, however, that graphics aren’t the most effective

communication method in every circumstance Luckily, the <img> tag includes two attributes

that enable you to describe your image using plain text: alt and longdesc

Trang 12

The alt attribute gives you a means to include a short description of a graphic It is used in

many ways:

As a page is loading over the Web, the image is first displayed as an empty rectangle if

L

the <img> tag contains width and height information Some browsers display the alt

description in this rectangle while the image is loading, offering the waiting user a ten preview of the forthcoming image

writ-In many browsers, the

L alt text displays as a tooltip when the user’s pointer passes over the graphic

A real benefit of

L alt text is providing input for browsers that don’t show graphics

Remember that text-only browsers are still in use, and some users, interested only in content, turn off the graphics to speed up the text display

The W3C is working toward standards for browsers for the visually impaired, and the

L alt text can be used to describe the image

For all these reasons, it’s good coding practice to associate an alt description with all your

graphics In Dreamweaver, you can enter this alternative text in the Alt text box of the Image

Property inspector

Tip

If the <img> tag does not contain an alt attribute, some screen readers read the filename when they

encounter the image, which slows down how quickly visually impaired users can get to the real information

on your page For images that are purely visual and don’t contribute to the meaning of your content, such as

bullets or spacer images, include a blank alt attribute To do this, open the Image property inspector and

select <empty> from the alt drop-down list n

Currently, the alt attribute is the most valuable tool you have for providing a textual

descrip-tion of your images However, some images are just too complicated to describe in a few words

and are too important to gloss over For these situations, the latest HTML specification includes

the longdesc attribute Although none of the major browsers currently support this attribute,

Dreamweaver is anticipating the future by enabling you to specify a longdesc for your images

In Dreamweaver, choose Edit ➪ Preferences (Dreamweaver ➪ Preferences), and, in the

Accessibility category, select the Images checkbox When you add a new image to your page,

the Image Tag Accessibility Attributes dialog box appears, as shown in Figure 8-11 In the Long

Description text box, click the folder icon to navigate to an HTML file that contains a textual

description of the image

Trang 13

The Image Tag Accessibility Attributes dialog box appears when you select the Images option in the

Accessibility Preferences

Caution

The Image Tag accessibility attributes dialog box is not displayed if you add a new image by dragging it

from the Files panel It does appear, however, if you drag the image from the assets panel, or use the Insert

panel or Insert menu to add the image n

Bordering a graphic

When you’re working with thumbnails (small versions of images) on your Web page, you may

need a quick way to distinguish one from another The border attribute enables you to place a

one-color rectangular border around any graphic To turn on the border, enter the desired width

of the border, measured in pixels, in the Border text box located on the lower half of the Image

Property inspector Entering a value of 0 explicitly turns off the border

Note

a preferred method for adding a border to an image is to use Cascading style sheets, described in Chapter 6

note that Cascading style sheets are not supported in older browsers n

One of the most frequent cries for help among beginning Web designers results from the sudden

appearance of a bright blue border around an image Whenever you assign a link to an image,

HTML automatically places a border around that image; the color is determined by the Page

Properties Link color, where the default is bright blue Dreamweaver intelligently assigns a 0 to

the border attribute whenever you enter a URL in the Link text box If you’ve already declared a

border value and enter a link, Dreamweaver won’t zero-out the border You can, of course,

over-ride the no-border option by entering a value in the Border text box

Specifying a lowsrc

Another option for loading Web page images, the lowsrc attribute, displays a smaller version of

a large graphics file while the larger file is loading The lowsrc file can be a grayscale version of

Trang 14

the original, or a version that is physically smaller or reduced in color or resolution This option

is designed to significantly reduce the file size for quick loading

Select your lowsrc file by clicking the file icon next to the Low Src text box in the Image Property

inspector The same criteria that apply to inserting your original image also apply to the lowsrc

picture

Tip

One handy lowsrc technique first proportionately scales down a large file in a graphics-processing program

This file becomes your lowsrc file Because browsers use the final image’s height and width information for

both the lowsrc and the final image, your visitors immediately see a blocky version of your graphic, which is

replaced by the final version when the picture is fully loaded n

Working with alignment options

Using CSS, images can be aligned to the left, right, or center — or rather, the line the images are

on can be so adjusted In fact, images have much more flexibility than text in terms of alignment

In addition to the same horizontal alignment options, you can align your images vertically in

nine different ways You can even turn a picture into a floating image type, enabling text to wrap

around it

Horizontal alignment

When you change the horizontal alignment of a line — from left to center or from center to

right — the entire paragraph moves Any inline images that are part of that paragraph also move

Likewise, selecting one of a series of inline images in a row and realigning it horizontally causes

all the images in the row to shift

In Dreamweaver, the horizontal alignment of an inline image is changed in exactly the same

way that you realign text — with CSS To change the alignment of an image, select it and then,

through the CSS Styles panel, change the text-align property to left, right, or center

Vertical alignment

Because you can place text next to an image — and images vary so greatly in size — HTML

includes a variety of options for specifying just how image and text line up As you can see from

the chart shown in Figure 8-12, a wide range of possibilities is available

To change the vertical alignment of any graphic in Dreamweaver, open the Align drop-down list

in the Image Property inspector and choose one of the options Dreamweaver writes your choice

into the align attribute of the <img> tag The various vertical alignment options are listed in

Table 8-1, and you can refer to Figure 8-12 for examples of each type of alignment

Trang 15

Browser Default No alignment attribute is included in the <img>

tag Most browsers use the baseline as the alignment default.

baseline of the surrounding text.

tallest object in the current line.

baseline of the current line.

Trang 16

Option Result

baseline of the surrounding text.

letter or object in the current line.

Absolute Middle The middle of the image is aligned with the middle

of the tallest text or object in the current line.

descenders (as in y, g, p, and so forth) that fall below the current baseline.

or table cell, and all text in the current line flows around the right side of the image.

browser or table cell, and all text in the current line flows around the left side of the image.

The last two alignment options, Left and Right, are special cases; details about how to use their

features are covered in the following section

Wrapping text

Most browsers support wrapping text around an image on a Web page — long a popular design

option in conventional publishing As noted in the preceding section, the Left and Right

align-ment options turn a picture into a floating image type This type is so called because the image

can move depending on the amount of text and the size of the browser window

Tip

Using both floating image types (Left and right) in combination, you can actually position images flush-left

and flush-right, with text in the middle Insert both images side by side and then set the leftmost image to

align left and the rightmost one to align right Insert your text immediately following the second image n

Your text wraps around the image depending on where the floating image is placed (or anchored)

If you enable the Anchor Points for Aligned Elements option in the Invisible Elements category

of Preferences, Dreamweaver inserts a Floating Image Anchor symbol to mark the floating

image’s place Note that the image itself may overlap the anchor, hiding the anchor from view

Figure 8-13 shows two examples of text wrapping: a left-aligned image with text flowing to the

right, and a right-aligned image with text flowing to the left

Trang 17

Aligning an image left or right enables text to wrap around your images

The Floating Image Anchor is not just a static symbol You can click and drag the anchor to a new

location and cause the paragraph to wrap in a different fashion Be careful, however If you delete

the anchor, you also delete the image it represents

You can also wrap a portion of the text around your left- or right-aligned picture and then force

the remaining text to appear below the floating image However, Dreamweaver cannot currently

insert the HTML code necessary to do this task through the Image Property inspector You have

to force an opening to appear by inserting a break tag, with a special clear attribute, where you

want the text to break This special <br> tag has three forms:

<br

L clear=left> — Causes the line to break and the following text to move down

vertically until no floating images are on the left

<br

L clear=right> — Causes the line to break and the following text to move down

vertically until no floating images are on the right

<br

L clear=all> — Moves the text following the image down until no floating images

are on either the left or the right

A quick way to add the clear attribute is to position your cursor where you want the text to

break, and press Shift+Enter Next, in Code view, right-click the <br> tag and select Edit Tag

Trang 18

Adding Background Images

In this chapter, you’ve learned about working with the surface graphics on a Web page You can

also place an image in the background of an HTML page This section covers some of the basic

techniques for incorporating a background image in your Dreamweaver page

Add an image to your background either by using the CSS Styles panel or by modifying the

Appearance (CSS) category of the Page Properties Either technique adds a background-image

property to a CSS rule

Cross-Reference

If you aren’t familiar with Cascading style sheets, you may want to read Chapter 6 before trying the following

procedure That chapter gets you started with general Css concepts and outlines specific options for

imple-menting background images n

To implement a background image using the CSS Styles panel, follow these steps:

1. Choose Window ➪ CSS Styles

2. On the CSS Styles panel, click Edit Styles and then click the New CSS Rule button

3. In the New CSS Rule dialog box, choose Tag from the Selector Type list, and in the Selector name drop-down list, select Body These selections create a background image for the entire document You can also select a different tag or choose the Make a Custom Style option to assign a background image to a single element on the page, such as a table cell or paragraph

4. Specify whether you want to save the style definition in an external style sheet or in the current document, and then click OK

5. In the CSS Style Definition dialog box, select the Background category

6. In the Background Image field, type the path and filename for the image file, or click

Browse to navigate to the file

7. Designate any other background options, and then click OK

To specify a background image using the Page Properties, choose Modify ➪ Page Properties or

select Page Properties from the Property inspector In the Page Properties dialog box, choose

the Appearance (CSS) category Select a graphic by clicking the Browse button next to the

Background Image text box You can use any file format supported by Dreamweaver — GIF,

JPEG, or PNG Choose your tiling options from the Repeat list

Note

although you can set background images (and colors) as a property of an hTML tag through the appearance

(hTML) category of the page properties dialog box, it’s not recommended for standards-based Web design n

Two key differences exist between background images and the foreground inline images

dis-cussed in the preceding sections of this chapter First and most obvious, all other text and

Trang 19

graphics on the Web page are superimposed over your chosen background image This capability

can bring extra depth and texture to your work; unfortunately, you have to make sure the

fore-ground text and images work well with the backfore-ground

Basically, you want to ascertain that enough contrast exists between foreground and background

You can set the default text and the various link colors using Cascading Style Sheets or through

the Page Properties dialog box, shown in Figure 8-14 When trying out a new background

pat-tern, you should set up some dummy text and links Then click the Apply button on the Page

Properties dialog box to test different color combinations

Figure 8-14

If you’re using a background image, be sure to check the default colors for text and links to make sure

enough contrast exists between background and foreground

TilingImages

Web designers use the tiling property of background images to create a variety of effects with very low

file-size overhead The columns typically found on one side of Web pages are a good example of tiling

Columns are popular because they enable the designer to place navigational buttons in a visual context

An easy way to create a column that runs the full length of your Web page is to use a long, narrow

background image

In the following figure, the background image is 45 pixels high, 800 pixels wide, and only 6KB in size

When the browser window is set at 640 × 480 or 800 × 600, the image is tiled down the page to create

the vertical column effect You could just as easily create an image 1,000 pixels high by 40 pixels wide

to create a horizontal column

Trang 20

When using Cascading Style Sheets to implement your background image, you can control whether the

image tiles horizontally, vertically, in both directions, or not at all

The second distinguishing feature of background images is that the viewing browser completely

fills either the browser window or the area behind the content of your Web page — whichever is

larger Suppose you have created a splash page with only a 200 × 200 foreground logo, and you’ve

incorporated an amazing 1,024 × 768 background that took you weeks to compose A user can’t see

the fruits of your labor in the background — unless he resizes his browser window to 1,024 × 768

On the other hand, if your background image is smaller than either the browser window or what

the Web page content needs to display, the browser and Dreamweaver repeat (tile) your image to

make up the difference

Tip

With Cascading style sheets, you not only can attach a background image to a page, but you can also attach a

background image to an individual element on a page, such as a single paragraph Cascading style sheets also

enable you to designate whether the background image should scroll with the foreground text, or if it should

remain stationary while the foreground text scrolls over the background n

Dividing the Web Page with Horizontal Rules

HTML includes a standard horizontal line that can divide your Web page into specific sections

The horizontal rule tag, <hr>, is a good tool for adding a little diversion to your page without

adding download time You can control the width (either absolutely or relative to the browser

window), the height, the alignment, and the shading property of the rule These horizontal

rules appear on a line by themselves; you cannot place text or images on the same line as a

horizontal rule

Trang 21

To insert a horizontal rule in your Web page in Dreamweaver, follow these steps:

1. Place your cursor where you want the horizontal rule to appear

2. From the Common category of the Insert panel, click the Horizontal Rule button or

choose Insert ➪ HTML ➪ Horizontal Rule Dreamweaver inserts the horizontal rule;

and the Property inspector, if visible, shows the attributes that you can change for a horizontal rule (see Figure 8-15)

Figure 8-15

The Horizontal Rule Property inspector controls the width, height, and alignment for these HTML lines

3. To change the width of the line, enter a value in the Property inspector width (W) text

box You can insert either an absolute width in pixels or a relative value as a percentage

of the screen:

To set a horizontal rule to an exact width, enter the measurement in pixels in the

L

width (W) text box and press the Tab key If it is not already showing, select Pixels

in the drop-down list

To set a horizontal rule to a width relative to the browser window, enter the

Trang 22

5. To change the alignment from the default (centered), open the Align drop-down list and choose another alignment.

6. To disable the default embossed look for the rule, clear the Shading checkbox

7. If you intend to reference your horizontal rule in JavaScript or in another application, you can give it a unique name Type the name in the unlabeled text box located directly

to the left of the H text box

Note

The hTML 4.0 standard lists the align, noshade, width, and size attributes of the <hr> tag as

depre-cated however, current browsers still support these attributes n

To modify any inserted horizontal rule, simply click it (If the Property inspector is not already

open, you have to double-click the rule.) As a general practice, size your horizontal rules using

the percentage option if you are using them to separate items on a full screen If you are using the

horizontal rules to divide items in a specifically sized table column or cell, use the pixel method

Tip

The shading property of the horizontal rule is most effective when your page background is a shade of gray

The default shading is black along the top and left, and white along the bottom and right The center line is

generally transparent (although Internet explorer enables you to assign a color attribute) If you use a

differ-ent background color or image, be sure to check the appearance of your horizontal rules in that context n

Many designers prefer to create elaborate horizontal rules; in fact, custom rules are an active area

of clip art design These types of horizontal rules are regular graphics and are inserted and

modi-fied as such

Including Banner Ads

Banner ads have become an essential aspect of the World Wide Web; for the Web to remain,

for the most part, freely accessible, advertising is needed to support the costs Banner ads have

evolved into the de facto standard Although numerous variations exist, a banner ad is typically

an animated GIF of a particular width and height, within a specified file size

The Standards and Practices Committee of the Interactive Advertising Bureau (IAB) established

a series of standard sizes for banner ads Although no law dictates that these guidelines have to

be followed, the vast majority of commercial sites adhere to the suggested dimensions The most

common banner sizes (in pixels) and their official names are listed in Table 8-2; additional

ban-ner guidelines are available at the IAB Web site (www.iab.net)

Acceptable file size for a banner ad is not as clearly specified, but it’s just as important The last

thing a hosting site wants is for a large, too-heavy banner to slow down the loading of its page Most

commercial sites have an established maximum file size for any given banner ad Generally,

ban-ner ads are around 30–40KB The lighter your banban-ner ad, the faster it loads and — as a direct

result — the more likely Web page visitors stick around to see it

Trang 23

Major sites often have additional criteria for using rich media in banner ads, such as Flash animations or

Javascript These may include file size, length of animation, behavior when the ad is clicked, and so on n

Inserting a banner ad on a Web page is very straightforward As with any other GIF file,

ani-mated or not, all you have to do is insert the image and assign the link As any advertiser can tell

you, the link is as important as the image itself, and you should take special care to ensure that it

is correct when inserted Advertising links are often quite complex because they not only link to

a specific page, but may also carry information about the referring site Several companies

Trang 24

moni-to communicate with these companies and handle the link Here’s a sample URL from CNet’s

News.com site:

http://home.cnet.com/cgi-acc/clickthru.acc? ; clickid=00001e145ea7d80f00000000&adt=003:10:100&edt=cnet&cat=1:1002:&site=CN

Obviously, copying and pasting such URLs is highly preferable to entering them by hand

Advertisements often come from an outside source, so a Web page designer may have to allow

space for the ad without incorporating the actual ad Some Web designers create a plain

rectan-gular image of the appropriate size to serve as a placeholder, until the actual image is ready In

Dreamweaver, placeholder ads can easily be maintained as Library items and placed as needed

from the Assets panel, as shown in Figure 8-16

Cross-Reference

see Chapter 29 for information on creating and using Dreamweaver Library items n

Figure 8-16

Use the Library to store standard banner ad images for use as placeholders

If you’d prefer not to use placeholder graphics as just described, you can instead insert a plain

<img> tag — with no src parameter When an <img> tag without an src attribute is in the

code, Dreamweaver displays a plain rectangle that can be resized to the proper banner ad

dimen-sions in the Property inspector

Trang 25

You can insert a placeholder image by clicking the Image Placeholder button on the Insert panel,

or by choosing Insert ➪ Image Objects ➪ Image Placeholder In the resulting Image Placeholder

dialog box, you can enter an image name, dimensions, color, and alternate text When the real

graphics file is ready, use the Src text box on the Property inspector to specify the new file The

image name and alternate text remain unchanged when you assign the new file, but the

dimen-sions automatically change to match those of the actual image

Inserting Rollover Images

Rollovers are among the most popular of all Web page effects A rollover (also known as a

mouse-over) occurs when the user’s pointer passes over an image and the image changes in some way It

may appear to glow or change color and/or shape When the pointer moves away from the graphic,

the image returns to its original form The rollover indicates interactivity and attempts to engage

the user with a little bit of flair

Rollovers are usually accomplished with a combination of HTML and JavaScript Dreamweaver

was among the first Web-authoring tools to automate the production of rollovers through its

Swap Image and Swap Image Restore behaviors Later versions of Dreamweaver make rollovers

even easier with the Rollover Image object With the Rollover Image object, you just pick two

images to make a rollover

Cross-Reference

If you use Fireworks as your image-editing tool, refer to Chapter 24 to learn another method for creating

roll-over images n

Technically speaking, a rollover is accomplished by manipulating an <img> tag’s src attribute

Recall that the src attribute is responsible for providing the actual filename of the graphic to be

displayed; it is, quite literally, the source of the image A rollover changes the value of src from

one image file to another Swapping the src value is analogous to having a picture within a frame

and changing the picture while keeping the frame

Note

The picture frame analogy is appropriate on one other level: It serves as a reminder of the size barrier

inher-ent in rollovers a rollover changes only one property of an <img> tag, the source — it cannot change any

other property, such as height or width For this reason, both your original image and the image displayed

during the rollover should be the same size If they are not, the alternate image is resized to match the

dimen-sions of the original image n

Dreamweaver’s Rollover Image object automatically changes the image back to its original source

when the user moves the pointer off the image Optionally, you can elect to preload the images

with the selection of a checkbox Preloading is a Web page technique that reads the intended file

or files into the browser’s memory before they are displayed With preloading, the images appear

on demand, without any download delay

Trang 26

Rollovers are typically used for buttons that, when clicked, open another Web page In fact,

JavaScript requires that an image include a link before it can detect when a user’s pointer moves over

it Dreamweaver automatically includes the minimum link necessary: the # link Although JavaScript

recognizes this symbol as indicating a link, no action is taken if the image is clicked by the user; the

#, by itself, is an empty link You can supply whatever link you want in the Rollover Image object

Tip

some browsers link to the top of the page when they encounter a # link If you want to create a rollover

image that doesn’t link anywhere, change the # to the following:

javascript:;

You can change this directly in Code view or in the Link field of the property inspector for the button n

To include a Rollover Image object in your Web page, follow these steps:

1. Place your cursor where you want the rollover image to appear and choose Insert ➪ Image Objects ➪ Rollover Image, or select Rollover Image from the Images menu on the Insert panel’s Common category You can also drag the Rollover Image button to any existing location on the Web page Dreamweaver opens the Insert Rollover Image dialog box shown in Figure 8-17

Figure 8-17

The Rollover Image object makes rollover graphics quick and easy

2. You can enter a unique name for the image in the Image Name text box, or you can use

the name automatically generated by Dreamweaver

3. In the Original Image text box, enter the path and name of the graphic you want played when the user’s mouse is not over the graphic You can also click the Browse but-ton to select the file Press Tab when you’re done

dis-4. In the Rollover Image text box, enter the path and name of the graphic file you want displayed when the user’s pointer is over the image You can also click the Browse but-ton to select the file

5. In the Alternate Text field, type a brief description of the graphic button

Trang 27

6. If desired, specify a link for the image by entering it in the When Clicked, Go To URL

text box or by clicking the Browse button to select the file

7. To enable images to load only when they are required, deselect the Preload Images

option Generally, it is best to leave this option selected (the default) so that the ance of the rollover is not delayed

appear-8. Click OK when you’re finished

Tip

Keep in mind that the rollover Image object inserts both the original image and its alternate, whereas the

swap Image technique is applied to an existing image in the Web page If you prefer to use the rollover Image

object rather than the swap Image behavior, nothing prevents you from deleting an existing image from the

Web page and inserting it again through the rollover Image object Just make sure that you note the path and

name of the image before you delete it, so you can find it again n

Summary

In this chapter, you learned how to include both foreground and background images in

Dreamweaver Understanding how images are handled in HTML is an absolute necessity for the

Web designer As you’re inserting images into your Web pages, keep these key points in mind:

Web pages are restricted to using specific graphic formats Virtually all current browsers

L

support GIF, JPEG, and PNG files Dreamweaver can preview all three image types

Images are inserted in the foreground in Dreamweaver through the Image button on the

Trang 28

Dreamweaver Technique:

Inserting anchors Targeting UrLs

Links are the Web Everything else about the medium can be

repli-cated in another form, but without links, there would be no World

Wide Web As your Web design work becomes more sophisticated,

you’ll find additional uses for links: sending mail, connecting to an FTP

site — even downloading software

In this chapter, you learn how Dreamweaver helps you manage various

types of links, as well as how to set anchors within documents to get

smooth and accurate navigation, and establish targets for your links To

give you a full picture of the possibilities, this chapter begins with an

overview of Internet addresses, called URLs

Understanding URLs

URL stands for Uniform Resource Locator An awkward phrase, it is one

that, nonetheless, describes itself well — the URL’s function is to provide

a standard method for finding anything on the Internet From Web pages

to newsgroups to the smallest graphic on the most esoteric of pages,

every-thing can be referenced through the URL mechanism

A typical URL for a Web page can have up to six different parts Each

part is separated by some combination of a slash, colon, and hash-mark

delimiter When entered as an attribute’s value, the entire URL is generally

Trang 29

enclosed within quotation marks to ensure that the address is read as one unit A generic URL

using all the parts looks like this:

L : — The URL scheme used to access the resource A scheme is an agreed-upon

mechanism for communication, typically between a client and a server The scheme to reference Web servers uses the Hypertext Transfer Protocol (HTTP) Other schemes and their related protocols are discussed later in this section

www.idest.com

L — The name of the server providing the resource The server can

be either a domain name (with or without the www prefix) or an Internet Protocol (IP) address, such as 199.227.52.143

:80

L — The port number to be used on the server Most URLs do not include a port

number, which is analogous to a telephone extension number on the server, because most servers use the defaults

/Dreamweaver

L — The directory path to the resource Depending on where the

resource (for example, the Web page) is located on the server, the following paths can

be specified: no path (indicating that the resource is in the public root of the server), a single folder name, or a number of folders and subfolders

/index.htm

L — The filename of the resource If the filename is omitted, the Web

browser looks for a default page, often named index.html or index.htm The browser reacts differently depending on the type of file For example, GIFs and JPEGs are displayed by themselves; executable files and archives (Zip, StuffIt, and so on) are downloaded

#bible

L — The named anchor in the HTML document This part is another optional

section The named anchor enables the Web designer to send the viewer to a lar section of an HTML page

particu-Although http is one of the most prevalent communication schemes used on the Internet, other

schemes are also available Whereas HTTP is used for accessing Web pages, the other schemes

are used for such things as transferring files between servers and clients or for sending e-mail

Table 9-1 describes the most common schemes used in URLs

Trang 30

Common URL Schemes and Associated Protocols

ftp:// File Transfer Protocol (FTP) Links to an FTP server that is typically used for

uploading and downloading files The server may be accessed anonymously, or it may require

a username and password.

http:// HyperText Transfer Protocol

(HTTP)

Used for connecting to a document available on

a World Wide Web server.

javascript: JavaScript Although it is not part of a true URL, some

browsers support a scheme of javascript:, indicating that the browser should execute JavaScript code This provides an easy way to execute JavaScript code when a user clicks

news:// Network News Transfer

Protocol (NNTP) Connects to the specified Usenet newsgroup Newsgroups are public, theme‑oriented message

boards on which anyone can post or reply to a message.

host computers and interact directly with the operating system software.

Part of the richness of today’s Web browsers stems from their capability to connect to all the

pre-ceding (and additional) services

Tip

The mailto: scheme enables you not only to open up a preaddressed e‑mail form, but also, with a little

extra work, to specify the topic For example, if Joe Lowery wants to include a link to his e‑mail address with

the subject heading “Book Feedback,” he can insert a link such as the following:

mailto:jlowery@idest.com?subject=Book%20Feedback

The question mark acts as a delimiter that enables a variable and a value to be passed to the browser; the

%20 is the decimal representation for a space that must be read by various servers When you’re trying to

encourage feedback from your Web page visitors, every little bit helps n

Trang 31

Surfing the Web with Hypertext

Often, you assign a link to a word or phrase on your page, an image such as a navigational button,

or a section of graphic for an image map (a large graphic in which various parts are links) To test

the link, you preview the page in a browser; links are not active in Dreamweaver’s Document

window

Designate links in HTML through the anchor tag pair: <a> and </a> The anchor tag generally

takes one main attribute — the hypertext reference, which is written as follows:

href=”link name”

When you create a link, the anchor pair surrounds the text or object that is being linked For

example, if you link the phrase Back to Home Page, it may look like the following:

<a href=”index.html”>Back to Home Page</a>

If you attach a link to the image logo.gif, your code looks as follows:

<a href=”home.html”><img src=”images/logo.gif”></a>

Creating a basic link in Dreamweaver is easy Simply follow these steps:

1. Select the text, image, or object you want to establish as a link

2. In the Property inspector, enter the URL in the Link text box as shown in Figure 9-1

You can use one of the following methods to do so:

Type the URL directly into the Link text box

L

Click the Browse for File folder icon to the right of the Link text box to open the

L

Select File dialog box, where you can browse for the file

Click the Point to File icon and drag your mouse to an existing page in the Files

L

panel or anchor on the current page This feature is explained later in this section

You can also create a link by dragging a URL from the Assets panel onto a text or image selection —

a procedure covered more fully later in this chapter

Finally, you can create a link using the Insert menu or Insert panel Without selecting any text,

choose Insert ➪ Hyperlink, or in the Common category of the Insert panel, click the Hyperlink

button The Hyperlink dialog box opens, and you can specify the hotspot text, the URL for the

link, and a link target (described later) This method also enables you to specify the following:

Tab index:

L A number specifying the order in which a user can tab through the page

Links with lower numbers are given focus first, and links with no tab index defined appear last in the tab order

Title field:

L A description of the link In Netscape 6.0 and Internet Explorer 6.0, the text

appears as a tooltip when the user holds the cursor over the link

Trang 32

You can enter your link directly into the Link text box, click the folder icon to browse for a file, or point to

the file directly with the Point to File icon

Link text field Point to File icon Browse to File icon

Note

If you don’t see the hyperlink dialog box when you insert a hyperlink, choose edit preferences (Dreamweaver

preferences) and, in the Common category, select the show Dialog When Inserting Objects option n

Regardless of how you create a link in Dreamweaver, a few restrictions exist for specifying URLs

Dreamweaver does not support any letters from the extended character set (also known as High

ASCII), such as ¡, à, or ñ Complete URLs must have fewer than a total of 255 characters You

should be cautious about using spaces in pathnames and, therefore, in URLs Although most

browsers can interpret the address, spaces are changed to a %20 symbol for proper UNIX usage

This change can make your URLs difficult to read

Text links are, for almost all browsers, rendered with a blue color and underlined Depending on

the background color for your page, you may want to change the color of text links to improve

readability You can specify the document-link color by choosing Modify ➪ Page Properties

and selecting the Links color box In Page Properties, you can also alter the color to which the

links change after being selected (the Visited Links color), and the color flashed when the link is

clicked (the Active Links color) All of these changes are written as CSS statements in the <head>

of the current document

Trang 33

Eliminating underlines from links

Disabling the underline for the anchor tag, <a>, which is normally associated with hyperlinked

text, is one modification commonly included in style sheets

Caution

Be careful when using this technique Underlined text is a standard method of indicating a hyperlink on the

Web, and some clients or users may find your pages not as intuitive if the underline indicator is no longer

visible n

To disable the underline on the anchor tag, follow these steps:

1. Open the CSS Styles panel by choosing Window ➪ CSS Styles The CSS Styles panel,

shown in Figure 9-2, displays existing styles and provides controls for creating and managing styles

Figure 9-2

The Dreamweaver CSS Styles panel helps you apply consistent styles to a Web page

Delete CSS Property Edit Style

Attach Style

Sheets

New CSS Rule

2. In the CSS Styles panel, click the New CSS Rule button This action opens the New

CSS Rule dialog box

3. Select the Tag option and choose the anchor tag, a, from the drop-down list Finally,

select Define In This Document Only to create an internal CSS style sheet or choose an external style sheet from the drop-down list Click OK, and the CSS Style Definition dialog box opens

Trang 34

You can also select the advanced option rather than Tag and choose a:link from the drop‑down list You

can even employ the a:hover style, which enables text to change color or style on rollover You must, how‑

ever, define the four Css selector styles in a particular order for them to work correctly start by defining the

a:link class and then proceed to define a:visited, a:hover, and a:active, in that order note that you

can preview only the a:link altered styles in Dreamweaver; to see the other styles, you need to preview the

The Style Definition window closes, and any style changes instantly take effect on your page If

you have any previously defined links, the underline disappears from them

Now, when viewed through a browser, any links that you insert on your page still function as

links — the user’s pointer still changes into a pointing hand, and the links are active — but no

underline appears

One variation on this technique is to make the underline appear only when the mouse rolls over

the link To accomplish this variation, define a CSS rule for the a:hover selector and set the

Decoration to Underline To eliminate the border around an image designated as a link, create a

rule like this:

a img { border: none; }

This CSS rule looks for any image within an anchor tag and removes the border

Inserting URLs from the Assets panel

Internet addresses get more complicated every day Trying to remember them all correctly

and avoid typos can make the Web designer’s job unnecessarily difficult You can use the

Dreamweaver Assets panel’s URLs category to drag-and-drop the trickiest URLs with ease

The Assets panel lists URLs that are already referenced somewhere within your site If you want

to link to the same URL again, just drag it from the Assets panel

Tip

To avoid rework, after you have typed a UrL for a link in a document, test that link in a browser to be sure it’s

correct Then when you assign the same UrL to other links using the assets panel, you can be confident that

the link works as expected n

Trang 35

The Assets panel lists only full Internet addresses — whether to files (such as http://www

.idest.com/dreamweaver/) or to e-mail addresses (such as mailto:jlowery@idest.com)

Document- or relative links are not listed as Assets To assign a link to a document- or

site-relative page, use one of the other linking methods discussed in this chapter, such as pointing to

a file

To assign a URL from the Assets panel, follow these steps:

1. If the Assets panel is not already visible, choose Window ➪ Assets to display it

2. Click the URLs icon on the side of the Assets panel to display that category (see

Figure 9-3)

Figure 9-3

Banish typos from your absolute URLs by dragging a link from the Assets panel to any selected text or

graphic

3. If necessary, click the Refresh Site List button on the Assets panel to list the most

cur-rent links found in the site

Note

as with other assets panel categories, you need to click the refresh site List button to make available all the

possible UrLs in a site alternatively, you could choose refresh site List from the context menu on the panel

either action causes Dreamweaver to scan all the Web pages within the site and extract all of the complete

Internet addresses it finds n

Trang 36

4. In the Document window, select the text or image you want the link assigned to.

5. Drag the desired link from the Assets panel onto the selected text or image; tively, highlight the link in the panel and click the Apply button

alterna-If you don’t select text or an image before dragging the URL from the Assets panel, a link is still

created in your document In this situation, Dreamweaver uses the URL name as the hotspot

The Edit button on the Assets panel is unavailable for the URLs category Links cannot be edited;

they can only be applied as shown in the preview area

Pointing to a file

Dreamweaver provides an alternative method of identifying a link — pointing to it By using the

Point to File icon on the Property inspector, you can quickly fill in the Link text box by dragging

your mouse to any existing named anchor or file visible in the Dreamweaver environment With

the Point to File feature, you can avoid browsing through folder after folder as you search for a file

you can clearly see onscreen

You can point to another open document, to a document in another frame in the same window,

or to any named anchor visible on the screen If your desired link is a named anchor located

far-ther down the page, Dreamweaver automatically scrolls to find it You can even point to a named

anchor in another document, and Dreamweaver will enter the full syntax correctly Named

anchors are covered in detail later in this chapter

Perhaps one of the slickest ways to apply the Point to File feature is to use it in tandem with the

Files panel The Files panel lists all the existing files in any given Web site, and when both it and

the Document window are onscreen, you can quickly point to any file

Pointing to a file uses what could be called a drag-and-release mouse technique, as opposed to

the more ordinary point-and-click or drag-and-drop method To select a new link using the Point

to File icon, follow these steps:

1. Select the text or the graphic that you’d like to make into a link

2. In the Property inspector, click and hold the Point to File icon located to the right of the

Link text box

3. Holding down the mouse button, drag the mouse until it is over an existing link or named anchor in the Document window or a file in the Files panel As you drag the mouse, a line extends from the Point to File icon, and the reminder Drag to a file to make a link appears in the Link text box

4. When you locate the file you want to link to, release the mouse button The filename with the accompanying path information is written into the Link text box, as shown in Figure 9-4

Trang 37

The Point to File icon enables you to quickly insert a link to any onscreen file

Point to File icon

Addressing types

Three types of URLs are used as links: absolute addresses, document-relative addresses, and

site-root–relative addresses The following list briefly looks at these address types:

Absolute addresses require the full URL, as follows:

L

http://www.adobe.com/products/dreamweaver/

This type of address is most often used for referencing links on another Web server

Document-relative addresses know the scheme, server, and path aspects of the URL

L

Include additional path information only if the link is outside the current Web page’s folder Links in the current document’s folder can be addressed with their filenames only To reference an item in a subfolder, just name the folder, enter a forward slash, and then enter the item’s filename, as follows:

Trang 38

You can set your preference for document‑ or site‑root–relative links on a site‑by‑site basis Open your site

Definition dialog box by double‑clicking the displayed site name in the Files panel drop‑down list In the

General category of the site Definition dialog box, choose the Links relative To option you’d prefer n

Checking links

A Webmaster must often perform the tedious but necessary task of verifying the links on all the

Web pages in a site Because of the Web’s fluid nature, links can work one day and break the

next Dreamweaver includes powerful link-checking and link-updating capabilities

Dreamweaver can generate reports for broken links, for external links (links to files outside your

site), and to orphaned files (files in your site with no links to them) You can check links for an

open document, for all documents in a site, or for selected documents in the Files panel

To check links in the current document, choose File ➪ Check Page ➪ Check Links, or press

Shift+F8 To generate a link report for the entire site, open the Files panel (Window ➪ Files), and,

from the Site menu, choose Check Links Sitewide To report on links for certain files, select the

files or folders in the Files panel, right-click (Control+click) and choose Check Links ➪ Selected

Files/Folders If the Link Checker panel is open, you can also click the Check Links button and

then select the scope of your check: current document, entire site, or selected files in the site

Tip

To stop an in‑progress link check, click the Cancel button in the Link Checker panel n

All these methods open the Link Checker panel, displaying the results of the link check In the

Show drop-down list at the top of the Link Checker panel, select the report you want to see:

Broken Links, External Links, or Orphaned Files The Orphaned Files report is available only if

you check the entire site The Broken Links report verifies not only clickable hotspots to other

HTML files, but also references to graphics and other external files

Linking to Files

Linking to files properly is an essential task in building Web sites In this Dreamweaver Technique, you

practice linking to other files from text phrases and images

1 From the Techniques site, expand the 09_Links folder and open the links_start file.

2 Select the phrase at the end of the first paragraph of placeholder text, Learn more

3 In the Property inspector next to the Link field, click Browse for File (the folder icon) to open the

Select File dialog box.

4 When the Select File dialog box opens, navigate to the 09_Links folder and choose split_level_

details.htm; click OK when you’re done.

continued

Trang 39

The proper path is entered into the Link field by Dreamweaver Assigning a link to a graphic is just

as easy.

5 Select the image next to the Ranch style 2 bedroom label.

6 From the Property inspector, drag the Point to File icon to the Files panel and hover over the new_

properties subfolder within the 09_Links folder The new_properties subfolder expands.

7 Select ranch_style.htm and release your left mouse button.

8 Repeat Steps 5–7, selecting the image next to the Multi‑level gardener’s delight label and selecting

multi_level.htm in the new_properties folder.

9 Save your page.

10 Press F12 (Option+F12) to test your links in the primary browser.

It’s especially important to let Dreamweaver write your links for you when target files are located

in a different folder Get into the habit of using the Browse for File and Point to File icons, and

you’ll save yourself from linking errors

You can save the link report by clicking the Save Report button on the Link Checker panel, or by

right-clicking (Control+clicking) in the panel and choosing Save Results from the pop-up menu

continued

Trang 40

Double-clicking an entry in the Link Checker panel opens the document where the error

occurred, with the broken link selected You can quickly correct the link using the Property

inspector or by choosing Modify ➪ Change Link To remove the link but leave the hotspot text,

clear the Link field in the Property inspector, or choose Modify ➪ Remove Link If the same URL

is referenced in more than one place in your site, you can change all occurrences of it at once

To do this, choose Site ➪ Change Link Sitewide from the main menus, and enter the URL to be

changed and then the new URL Finally, click OK

Adding an E‑mail Link

E-mail links are very common on the Web When a user clicks an e-mail link, it displays a

win-dow for sending a new e-mail message (rather than opening a new Web page as a regular link

does) The message window is convenient because it is preaddressed to the recipient All the user

has to do is add a subject, enter a message, and click Send

Dreamweaver includes an object that streamlines the process of adding e-mail links Just enter

the text of the line and the e-mail address, and the link is ready E-mail links, like other links, do

not work when clicked in Dreamweaver; they must be previewed in a browser

To enter an e-mail link, follow these steps:

1. Position your cursor where you want the e-mail link to appear

2. From the Common category on the Insert panel, click the E-mail Link button The

E-mail Link dialog box, shown in Figure 9-5, appears

Figure 9-5

The Email Link dialog box helps you create links that make it simple for your Web page visitors to send

e‑mail messages

3. Enter the visible text for the link in the Text field

4. Enter the e-mail address in the E-Mail field

Caution

The e‑mail address must be in the format name@company.com Dreamweaver does not check to ensure that

you’ve entered the address in the proper format n

5. Click OK when you’re finished

Ngày đăng: 08/08/2014, 20:22

TỪ KHÓA LIÊN QUAN