1 designing a web page working with fonts, colors, and graphics tutorial 3

55
1 Designing a Web Page Designing a Web Page Working with Fonts, Colors, Working with Fonts, Colors, and Graphics and Graphics Tutorial 3

Post on 20-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

11

Designing a Web PageDesigning a Web Page

Working with Fonts, Colors, and Working with Fonts, Colors, and GraphicsGraphics

Tutorial 3

Page 2: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

2

Working with Color in HTMLWorking with Color in HTML Color - immediate communication, doesn’t require Color - immediate communication, doesn’t require

words - global medium - U.S., red = danger, China = words - global medium - U.S., red = danger, China = joy, Japan = anger, Middle East = evil - know your joy, Japan = anger, Middle East = evil - know your audienceaudience

Using color will make your web pages:Using color will make your web pages: visually interesting and pleasingvisually interesting and pleasing eye-catching for the readereye-catching for the reader Draw usersDraw users Overall color schemeOverall color scheme

HTML is a text-based language, requiring you to HTML is a text-based language, requiring you to define your colors in textual termsdefine your colors in textual terms

HTML identifies a color in one of two ways:HTML identifies a color in one of two ways: by the color value - numerical or hexidecimalby the color value - numerical or hexidecimal by the color nameby the color name

Page 3: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

3

Basic Principles of Color TheoryBasic Principles of Color Theory

Any color - combination of three Any color - combination of three primaryprimary colors: colors: redred, , greengreen, and , and blue - RGB Tripletblue - RGB Triplet

By varying the intensity of each primary color - create By varying the intensity of each primary color - create almost any color and any shade of coloralmost any color and any shade of color

This principle allows a computer monitor to combine This principle allows a computer monitor to combine pixels of red, green, and blue to create the array of pixels of red, green, and blue to create the array of colors you see on your screencolors you see on your screen

Active/passive colorsActive/passive colors Active - warm, high-saturation, bright colors - come forward, Active - warm, high-saturation, bright colors - come forward,

closer proximity, ie. Red, orangecloser proximity, ie. Red, orange Passive - cool, low-saturation, dark - visually recede, Passive - cool, low-saturation, dark - visually recede,

sensation of distance, ie. Blue, greensensation of distance, ie. Blue, green

Page 4: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

4

Adding the Three Primary ColorsAdding the Three Primary Colors

Primary color model for light

Page 5: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

5

Page 6: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

6

Page 7: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

7

Page 8: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

8

Page 9: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

9

RGB (Red, Green, and Blue) TripletsRGB (Red, Green, and Blue) Triplets

Software programs - Web browser - define Software programs - Web browser - define color mathematicallycolor mathematically

The intensity of each of three colors (RGB) is The intensity of each of three colors (RGB) is assigned a number from 0 (absence of color) to assigned a number from 0 (absence of color) to 255 (highest intensity)255 (highest intensity)

In this way, 255In this way, 25533, or more than 16.7 million, , or more than 16.7 million, distinct colors can be defineddistinct colors can be defined

Each color is represented by a triplet of Each color is represented by a triplet of numbers, called an numbers, called an RGB tripletRGB triplet, based on the , based on the strength of its strength of its RRed, ed, GGreen, and reen, and BBlue lue componentscomponents

Page 10: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

10

RGB Triplets ExamplesRGB Triplets Examples

White - triplet of (255,255,255), indicating that red, White - triplet of (255,255,255), indicating that red, green, and blue are equally mixed at the highest green, and blue are equally mixed at the highest intensityintensity

Yellow - triplet (255,255,0) because it is an equal Yellow - triplet (255,255,0) because it is an equal mixture of red and green with no presence of bluemixture of red and green with no presence of blue

Color harmony - user respond positivelyColor harmony - user respond positively Pleasing arrangement of parts, inner sense of Pleasing arrangement of parts, inner sense of

order, visual balance - not boring (not enough color) order, visual balance - not boring (not enough color) nor chaotic (overwhelm with too much color)nor chaotic (overwhelm with too much color)

Human brain rejects what it doesn’t understandHuman brain rejects what it doesn’t understand

Page 11: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

11

A Typical Colors Dialog BoxA Typical Colors Dialog Box

• In most programs, you make your color choices with visual clues, usually without being aware of the underlying RGB triplet.

• This figure shows a typical dialog box in which you would make color selections based on the appearance of the color, rather than on the RGB values.

Page 12: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

12

Hexadecimal ValuesHexadecimal Values

HTML requires color values be entered as HTML requires color values be entered as hexadecimalshexadecimals

A A hexadecimalhexadecimal is a number based on base-16 is a number based on base-16 mathematics rather than base-10 mathematics that we mathematics rather than base-10 mathematics that we use every dayuse every day in base 10 counting, you use combination of 10 characters in base 10 counting, you use combination of 10 characters

(0 through 9) to represent numerical values(0 through 9) to represent numerical values hexadecimals include six extra characters: A (for 10), B (for hexadecimals include six extra characters: A (for 10), B (for

11), C (for 12), D (for 13), E (for 14), and F (for 15)11), C (for 12), D (for 13), E (for 14), and F (for 15) for values above 15, you use a combination of the 16 for values above 15, you use a combination of the 16

characters; 16 is expressed as “10”, 17 is expressed as “11”, characters; 16 is expressed as “10”, 17 is expressed as “11”, and so forthand so forth

Page 13: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

13

Hexadecimal ValuesHexadecimal Values

To represent a number in hexadecimal terms, you To represent a number in hexadecimal terms, you convert the value to multiples of 16 plus a remainder. convert the value to multiples of 16 plus a remainder. For example:For example: 21 is equal to (16 x 1) + 5, so its hexadecimal 21 is equal to (16 x 1) + 5, so its hexadecimal

representation is 15representation is 15 the number 255 is equal to (16 x 15) + 15, or FF in the number 255 is equal to (16 x 15) + 15, or FF in

hexadecimal format (remember that F = 15 in hexadecimal format (remember that F = 15 in hexadecimal)hexadecimal)

in the case of the number 255, the first F represents in the case of the number 255, the first F represents the number of times 16 goes into 255 (which is 15), the number of times 16 goes into 255 (which is 15), and the second F represents the remainder of 15and the second F represents the remainder of 15

Once you know the RGB triplet of a color, the color Once you know the RGB triplet of a color, the color needs to be converted to the hexadecimal formatneeds to be converted to the hexadecimal format

Page 14: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

14

Using Color ValuesUsing Color Values

A A palettepalette - selection of colors - selection of colors When a browser encounters a color that is not in its palette, it When a browser encounters a color that is not in its palette, it

attempts to render the color; this is called attempts to render the color; this is called ditheringdithering Use colors from the Use colors from the safety palettesafety palette to avoid dithering to avoid dithering The 216 colors in the safety palette are known as The 216 colors in the safety palette are known as Web-safe colorsWeb-safe colors

Page 15: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

15

The 16 Basic Color NamesThe 16 Basic Color Names

The 16 basic color names that are recognized by all versions of HTML and XHTML.

Page 16: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

16

Partial List of Extended Color NamesPartial List of Extended Color Names

Partial list of extended color names

Page 17: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

17

Defining Foreground and Background Defining Foreground and Background ColorsColors

Figure ground relationship is very important - color difference Figure ground relationship is very important - color difference creates contrast - more contrast, more visible - critical to creates contrast - more contrast, more visible - critical to readabilityreadability Good typographic communication is not pretty, it is smartGood typographic communication is not pretty, it is smart

Foreground color definition (text):Foreground color definition (text): color: color: colorcolor

colorcolor is either the color value or the color nameis either the color value or the color name Background color definition:Background color definition:

background-color: background-color: colorcolor You can apply foreground and background colors to any page You can apply foreground and background colors to any page

elementelement Complementary colors - directly opposite each other on the Complementary colors - directly opposite each other on the

color wheel - maximum contrast, ie. Purple/greencolor wheel - maximum contrast, ie. Purple/green

Page 18: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

18

Defining Foreground and Background ColorsDefining Foreground and Background Colors

Selecting color - three factorsSelecting color - three factors Intuition - apply personal sensitivityIntuition - apply personal sensitivity Knowledge - another element in designKnowledge - another element in design Experimentation - experienceExperimentation - experience

To define the background color for an entire page:To define the background color for an entire page: Add the bgcolor attribute to the <body> tagAdd the bgcolor attribute to the <body> tag

To define the text color for an entire page:To define the text color for an entire page: Use the text attributeUse the text attribute

An example of background and text color changes An example of background and text color changes including the color’s hexadecimal value:including the color’s hexadecimal value: <body bgcolor=“yellow” text=“#99CCFF”><body bgcolor=“yellow” text=“#99CCFF”>

Page 19: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

19

Defining Foreground and Background Defining Foreground and Background ColorsColors

Page 20: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

20

Working with Fonts and Text StylesWorking with Fonts and Text Styles

A A specific fontspecific font is a font such as Times New Roman, is a font such as Times New Roman, Arial, or Garamond. The font is installed on a user’s Arial, or Garamond. The font is installed on a user’s computercomputer

A A generic fontgeneric font refers to the font’s general appearance refers to the font’s general appearance Cannot be sure if specific font is on user’s computer - Cannot be sure if specific font is on user’s computer -

specify a list of three fonts - in order of preference, specify a list of three fonts - in order of preference, end list with generic fontend list with generic font

font-family: Arial, Helvetica, sans-seriffont-family: Arial, Helvetica, sans-serif

Page 21: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

21

Working with Fonts and Text StylesWorking with Fonts and Text Styles

Generic fonts

Page 22: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

22

Using the Using the <font><font> Tag Tag

The The <font><font> tag allows - specify the color, tag allows - specify the color, the size, and the font to be used for text on a the size, and the font to be used for text on a Web pageWeb page

The syntax for the The syntax for the <font><font> tag is: tag is:<font size=“size” color=“color” <font size=“size” color=“color” face=“face”> text </font>face=“face”> text </font>

sizesize attribute allows - specify the font size of the attribute allows - specify the font size of the texttext

colorcolor attribute allows - change the color of attribute allows - change the color of individual characters or wordsindividual characters or words

faceface attribute specifies a particular font for a attribute specifies a particular font for a section of textsection of text

Page 23: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

23

Changing the Font ColorChanging the Font Color

The The colorcolor attribute of the attribute of the <font><font> tag allows - tag allows - change the color of individual characters or wordschange the color of individual characters or words

Specify the color in the Specify the color in the <font><font> tag by using either a tag by using either a color name or color valuecolor name or color value for example, to change the color of the word for example, to change the color of the word

““AracadiumAracadium” to the hexadecimal color value 8000C0, ” to the hexadecimal color value 8000C0, you would enter the following HTML tag: you would enter the following HTML tag: <font <font color=“#8000C0”> Arcadium</font>color=“#8000C0”> Arcadium</font>

If there is no color specified in the If there is no color specified in the <body><body> tag, tag, the default colors of the Web browser is usedthe default colors of the Web browser is used

Page 24: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

24

Setting the Font SizeSetting the Font Size

The style to change the font size of text within an The style to change the font size of text within an element:element: font-size: font-size: lengthlength

Absolute unitsAbsolute units define a font size using one of five define a font size using one of five standard units of measurement:standard units of measurement: Millimeters (mm)Millimeters (mm) Centimeters (cm)Centimeters (cm) Inches (in)Inches (in) Points (pt)Points (pt) Picas (pc)Picas (pc)

Relative unitsRelative units - - express size relative to the size express size relative to the size of the standard characterof the standard character

Page 25: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

25

Spacing and IndentationSpacing and Indentation

TrackingTracking - amount of space between words - amount of space between words and phrases and phrases word-spacing: word-spacing: valuevalue

KerningKerning - amount of space between pairs of - amount of space between pairs of letters letters letter-spacing: letter-spacing: valuevalue

LeadingLeading - space between lines of text - space between lines of text line-height: line-height: lengthlength Text-indent:Text-indent: value value Hanging indentHanging indent

Page 26: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

26

Font Styles and WeightsFont Styles and Weights To specify font styles, use the following style: To specify font styles, use the following style:

font-style: font-style: typetype To control font weight for any page element: To control font weight for any page element:

font-weight: font-weight: weightweight To change the appearance of your text: To change the appearance of your text:

text-decoration: text-decoration: typetype Underline, overline: Underline, overline:

text-decoration: text-decoration: underline overlineunderline overline Capitalize: Capitalize:

text-transform: text-transform: capitalizecapitalize Uppercase letters, small font: Uppercase letters, small font:

font-variant: font-variant: typetype

Page 27: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

27

Text AlignmentText Alignment

Page 28: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

28

Choosing an Image FormatChoosing an Image Format

Two file formats: GIF and JPEGTwo file formats: GIF and JPEG GIF (Graphics Interchange Format)GIF (Graphics Interchange Format) - most - most

commonly used image format on the Web.commonly used image format on the Web. Compatible with virtually all browsers.Compatible with virtually all browsers. GIF files are limited to displaying 256 colors.GIF files are limited to displaying 256 colors. Often used for graphics requiring fewer colors, Often used for graphics requiring fewer colors,

such as clip art images, line art, logos, and icons.such as clip art images, line art, logos, and icons. Images that require more color depth, such as Images that require more color depth, such as

photographs, can appear grainy when saved as photographs, can appear grainy when saved as GIF files.GIF files.

Page 29: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

29

Interlaced and Noninterlaced GIFsInterlaced and Noninterlaced GIFs

InterlacingInterlacing - way the GIF is saved by the - way the GIF is saved by the graphics softwaregraphics software

noninterlacednoninterlaced GIF the image is saved one line GIF the image is saved one line at a time, starting from the top of the graphic at a time, starting from the top of the graphic and moving downwardand moving downward

interlacedinterlaced GIFs, the image is saved and GIFs, the image is saved and retrieved “retrieved “stepwisestepwise”” For example, every fifth line of the image might For example, every fifth line of the image might

appear first, followed by every sixth line, and so appear first, followed by every sixth line, and so forth through the remaining rowsforth through the remaining rows

Page 30: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

30

Noninterlaced GraphicNoninterlaced Graphic

A noninterlaced GIF appears as it is slowly retrieved by the Web browser.

If the graphic is large, it might take several minutes for the entire image to appear, which can frustrate the visitors to your Web page.

top appears first

Image appears one line at a

time

entire image is retrieved

Page 31: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

31

Interlaced GraphicInterlaced Graphic

This figure shows the effect of interlacing, which is when the graphic starts out as a blurry representation of the final image, then gradually comes into focus-unlike the noninterlaced graphic, which is always a sharp image as it’s being retrieved, although an incomplete one.

a rough image appears first

image starts to show more detail

final image is crisp and

detailed

Page 32: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

32

Transparent GIFsTransparent GIFs

A A transparent colortransparent color is a color from the is a color from the image that is not displayed when the image image that is not displayed when the image is viewed in an applicationis viewed in an application

In place of a transparent color, the browser In place of a transparent color, the browser will display whatever is on the page will display whatever is on the page backgroundbackground

Creating a transparent color depends on the Creating a transparent color depends on the graphic software usedgraphic software used

Many applications include the option to Many applications include the option to designate transparent color when saving the designate transparent color when saving the image i.e. PhotoShopimage i.e. PhotoShop

Page 33: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

33

Animated GIFsAnimated GIFs

One of the most popular uses of GIFs is to create One of the most popular uses of GIFs is to create animated imagesanimated images

Animated GIFs are easy to create and smaller in Animated GIFs are easy to create and smaller in sizesize

An An animated GIFanimated GIF is composed of several images is composed of several images that are displayed one after the other in rapid that are displayed one after the other in rapid successionsuccession

Animated GIFs are an effective way to compose Animated GIFs are an effective way to compose slide shows or to simulate motionslide shows or to simulate motion

Page 34: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

34

Animated GIFsAnimated GIFs

Animated GIF files are typically larger than Animated GIF files are typically larger than static GIF imagesstatic GIF images

The use of animated GIFs can greatly increase The use of animated GIFs can greatly increase the size of a Web pagethe size of a Web page

Be careful not to overwhelm the user with Be careful not to overwhelm the user with animated imagesanimated images

Animated GIFs are limited to 256 colors and Animated GIFs are limited to 256 colors and can use transparent colorscan use transparent colors

Early browser versions may not support Early browser versions may not support animated GIFsanimated GIFs

Page 35: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

35

JPEG ImagesJPEG Images

JPEG - joint photographic experts groupJPEG - joint photographic experts group Up to 16.7 million colorsUp to 16.7 million colors Good for photographs and images that require a wide Good for photographs and images that require a wide

spectrum of colorspectrum of color CompressedCompressed Progressive JPEG - support - similar to interlacingProgressive JPEG - support - similar to interlacing

Page 36: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

36

Portable Network Graphics (PNG)Portable Network Graphics (PNG)

PNG files use a free and open file format and can PNG files use a free and open file format and can display more colors than GIFs - up to full 16.7 display more colors than GIFs - up to full 16.7 million colorsmillion colors

Support most of same features as GIF - animation, Support most of same features as GIF - animation, interlacing, transparencyinterlacing, transparency

PNGs compressed like JPEGPNGs compressed like JPEG PNGs do allow transparent colors, but not all PNGs do allow transparent colors, but not all

browsers support this featurebrowsers support this feature

Page 37: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

37

Controlling Image AlignmentControlling Image Alignment

The syntax for the float The syntax for the float style is: style is:

floatfloat: position: position

Page 38: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

38

Controlling Image AlignmentControlling Image Alignment

The The alignalign attribute can control the alignment of attribute can control the alignment of an image with the an image with the <img><img> tag tag

The syntax for the align attribute is: The syntax for the align attribute is:

<img align<img align=“position” =“position” //>> alignmentalignment indicates how you want the graphic indicates how you want the graphic

aligned in relation to the surrounding textaligned in relation to the surrounding text Clearing an element - prevent other content Clearing an element - prevent other content

from wrapping around floating elementfrom wrapping around floating element

Page 39: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

39

Alignment OptionsAlignment Options

Aligns the top of the object with the top of the text. The top of the text is the baseline plus the standard height of an ascender in the text.

top

Aligns the top of the object with the absolute top of the surrounding text. The absolute top is the baseline plus the height of the largest ascender in the text.

texttop

Aligns the object to the right of the surrounding text. All subsequent text flows to the left of the object.right

Aligns the middle of the object with the surrounding text.middle

Aligns the object to the left of the surrounding text. All preceding and subsequent text flows to the right of the object.left

Aligns the bottom of the object with the bottom of the surrounding text. The bottom is equal to the baseline minus the standard height of a descender in the text.

bottom

Aligns the bottom of the object with the baseline of the surrounding text.baseline

Aligns the middle of the object with the middle of the surrounding text. The absolute middle is the midpoint between the absolute bottom and text top of the surrounding text.

absmiddle

Aligns the bottom of the object with the absolute bottom of the surrounding text. The absolute bottom is equal to the baseline of the text minus the height of the largest descender in the text.

absbottom

Descriptionalign=

Page 40: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

40

MarginsMargins

Control your margins with the following four styles:Control your margins with the following four styles: margin-top: margin-top: lengthlength margin-right: margin-right: lengthlength margin-bottom: margin-bottom: lengthlength margin-left: margin-left: lengthlength

Margin values can also be negative - this creates an Margin values can also be negative - this creates an overlay effect by forcing the browser to render one overlay effect by forcing the browser to render one element on top of anotherelement on top of another

You can also combine the four margin styles into a You can also combine the four margin styles into a single stylesingle style

Page 41: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

41

Setting Image SizeSetting Image Size

Browser will display image in saved Browser will display image in saved sizesize

Decrease image size but not image Decrease image size but not image file sizefile size Change file size with image editing Change file size with image editing application - Paintapplication - Paint

Specify height and width of image - Specify height and width of image - browser does not have to calculate browser does not have to calculate dimensions - reduce time to dimensions - reduce time to downloaddownload

Page 42: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

42

Inserting a Background ImageInserting a Background Image

The The backgroundbackground attribute allows an image file attribute allows an image file for the background of a Web pagefor the background of a Web page

The syntax for inserting a background image is: The syntax for inserting a background image is: background-image: url(background-image: url(urlurl)) URLURL is the location and filename of the graphic file is the location and filename of the graphic file

you want to use for the background of the Web you want to use for the background of the Web pagepage For example, to use an image named “For example, to use an image named “bricks.gifbricks.gif” as a ” as a

background image, you would use the tag: background image, you would use the tag: <body <body background=“brick.gif”>background=“brick.gif”>

Page 43: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

43

Background ImageBackground Image

In choosing a background image, you should In choosing a background image, you should remember the following:remember the following: use an image that will not detract from the text on use an image that will not detract from the text on

the Web page, making it hard to readthe Web page, making it hard to read do not use a large image file (more than 20 do not use a large image file (more than 20

kilobytes) kilobytes) large and complicated backgrounds will increase the time large and complicated backgrounds will increase the time

it takes a page to loadit takes a page to load

be sure to take into consideration how an image file be sure to take into consideration how an image file looks when it is tiled in the backgroundlooks when it is tiled in the background

Page 44: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

44

Background Image OptionsBackground Image Options

background-repeat: type

Page 45: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

45

Understanding Image MapsUnderstanding Image Maps

To use a single image to access multiple targets, you To use a single image to access multiple targets, you must set up hotspots within the imagemust set up hotspots within the image

A A hotspothotspot is a defined area of the image that acts as is a defined area of the image that acts as a hypertext linka hypertext link

When a user clicks within a hotspot, the hyperlink is When a user clicks within a hotspot, the hyperlink is activatedactivated

Hotspots are defined through the use of Hotspots are defined through the use of image mapsimage maps, , which list the positions of all hotspots within an imagewhich list the positions of all hotspots within an image

There are two types of image maps: There are two types of image maps: server-side server-side image mapsimage maps and and client-side image mapsclient-side image maps

Page 46: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

46

Image MapsImage Maps

Page 47: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

47

Server-Side Image MapsServer-Side Image Maps

In a In a server-side image mapserver-side image map, the image map is , the image map is stored on the Web serverstored on the Web server

Server-side image maps are supported by most Server-side image maps are supported by most graphical browsersgraphical browsers

Server-side image maps can be slow to operateServer-side image maps can be slow to operate The browser’s status bar does not display the The browser’s status bar does not display the

target of each hotspottarget of each hotspot

Page 48: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

48

Server-Side Image MapsServer-Side Image Maps

User clicks a hotspot on the image map

The server sends the destination document back to the user

The server consults the image map and accesses the link indicated on the map

Page 49: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

49

Client-Side Image MapsClient-Side Image Maps

A A client-side image mapclient-side image map is inserted in an is inserted in an image map into the HTML fileimage map into the HTML file

The browser locally processes the image mapThe browser locally processes the image map Because all of the processing is done locally, Because all of the processing is done locally,

you can easily test Web pagesyou can easily test Web pages More responsive than server-side mapsMore responsive than server-side maps The browser’s status bar displays the target of The browser’s status bar displays the target of

each hotspoteach hotspot Older browsers do not support client-side Older browsers do not support client-side

imagesimages

Page 50: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

50

Defining Image Map HotspotsDefining Image Map Hotspots

Define a hotspot using two properties:Define a hotspot using two properties: Its location in the imageIts location in the image Its shapeIts shape

Syntax of the hotspot element:Syntax of the hotspot element:<area shape=<area shape=“shape”“shape” coords= coords=“coordinates”“coordinates” href=href=“url” “url” alt=alt=“text”“text” /> />

Page 51: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

51

Defining Image Map HotspotsDefining Image Map Hotspots

Use a special program that determines the Use a special program that determines the image map coordinatesimage map coordinates

Most image map programs generate the Most image map programs generate the coordinates for hotspots, as well as, the coordinates for hotspots, as well as, the necessary HTML codenecessary HTML code

Page 52: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

52

Creating a Rectangular HotspotCreating a Rectangular Hotspot

Two points define a Two points define a rectangular hotspotrectangular hotspot:: the upper-left cornerthe upper-left corner the lower-right cornerthe lower-right corner

A sample code for a A sample code for a rectangular hotspotrectangular hotspot is: is:

<area shape=“rect” coords=“384,61,499,271” <area shape=“rect” coords=“384,61,499,271” href=“water.htm”>href=“water.htm”>

coordinatescoordinates are entered as a series of four numbers are entered as a series of four numbers separated by commasseparated by commas

HTML expects that the first two numbers represent the HTML expects that the first two numbers represent the coordinates for the upper-left corner of the rectangle, and coordinates for the upper-left corner of the rectangle, and the second two numbers indicate the location of the lower-the second two numbers indicate the location of the lower-right cornerright corner

the the hotspothotspot is a hypertext link to water.htm is a hypertext link to water.htm

Page 53: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

53

Creating a Circular HotspotCreating a Circular Hotspot

A A circular hotspotcircular hotspot is defined by the location of is defined by the location of its center and its radiusits center and its radius

A sample code for a A sample code for a circular hotspotcircular hotspot is: is:

<area shape=“circle” coords=“307,137,66” <area shape=“circle” coords=“307,137,66” href=“karts.htm”>href=“karts.htm”>

coordinatescoordinates are (307, 137), and it has a radius of 66 are (307, 137), and it has a radius of 66 pixelspixels

the the hotspothotspot is a hypertext link to karts.htm is a hypertext link to karts.htm

Page 54: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

54

Creating a Polygonal HotspotCreating a Polygonal Hotspot

To create a polygonal hotspot, you enter To create a polygonal hotspot, you enter the coordinates for each vertex in the the coordinates for each vertex in the shapeshape

A sample code for a A sample code for a polygonal hotspotpolygonal hotspot is: is:

<area shape=“polygon” <area shape=“polygon” coords=“13,60,13,270,370,270,370,225,coords=“13,60,13,270,370,270,370,225,230,225,230,60” href=“rides.htm”>230,225,230,60” href=“rides.htm”>

coordinatescoordinates are for each vertex in the shape. are for each vertex in the shape. the the hotspothotspot is a hypertext link to rides.htm is a hypertext link to rides.htm

Page 55: 1 Designing a Web Page Working with Fonts, Colors, and Graphics Tutorial 3

55

Assign #4Assign #4 - Case 1, pg. 163-165 - print - Case 1, pg. 163-165 - print HTML code - pixal.htm, index.htm; HTML code - pixal.htm, index.htm;

Case 2, pg. 165-167 - print HTML code - Case 2, pg. 165-167 - print HTML code - king.htm. king.htm.

Due 10/12Due 10/12