chapter 7 graphics and color. 2 principles of web design chapter 7 objectives understand the...

64
Chapter 7 Graphics and Color

Upload: aubrey-bishop

Post on 28-Dec-2015

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

Chapter 7

Graphics and Color

Page 2: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

2

Principles of Web Design Chapter 7

Objectives

• Understand the differences between the Web-based image file formats - GIF, JPG, and PNG

• Know which type of file format to use for which type of image

• Understand the basics of computer color

Page 3: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

3

Principles of Web Design Chapter 7

Objectives

• Use the <IMG> element and attributes to effectively display images

• Use hexadecimal color values to add color to your pages

Page 4: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

4

Principles of Web Design Chapter 7

File Format Basics

• You can currently use only three image file formats on the Web: GIF, JPG, and PNG.

• These formats all compress images to create smaller files. Knowing which file format to use for which type of image is important.

• If you choose the wrong file type, your image won’t compress or display properly.

Page 5: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

5

Principles of Web Design Chapter 7

GIF Format

• GIF uses a lossless compression technique, meaning that no color information is discarded when the image is compressed

• The color depth of GIF is 8-bit, allowing a palette of no more than 256 colors

• GIF excels at compressing and displaying flat color areas, making it the logical choice for line art and color graphics

Page 6: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

6

Principles of Web Design Chapter 7

GIF Transparency

• With GIF files, you can choose any one color in an image to appear as transparent in the browser.

• The background color or pattern will show through the areas that you have designated as transparent.

• Using transparent areas allows you to create graphics that appear to have an irregular outside shape, rather than being bounded by a rectangle.

Page 7: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

7

Principles of Web Design Chapter 7

GIF Transparency

• Using transparent areas allows you to create graphics that appear to have an irregular outside shape, rather than being bounded by a rectangle.

Page 8: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

8

Principles of Web Design Chapter 7

Page 9: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

9

Principles of Web Design Chapter 7

GIF Animation

• The GIF format lets you store multiple images and timing information about the images in a single file.

• This means that you can build animations consisting of multiple static images that play continuously, creating the illusion of motion.

Page 10: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

10

Principles of Web Design Chapter 7

Page 11: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

11

Principles of Web Design Chapter 7

Page 12: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

12

Principles of Web Design Chapter 7

JPG Format

• JPG is best for photographs or continuous tone images.

• JPGs are 24-bit RGB images that allow millions of colors.

• JPGs use a “lossy” compression routine especially designed for photographic images. When the image is compressed, some color information is discarded, resulting in a loss of quality from the original image.

Page 13: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

13

Principles of Web Design Chapter 7

JPG Format• When you create the JPG file, you can also

manually balance the amount of compression versus the resulting image quality.

• The higher the compression, the lower the image quality. You can play with this setting to create files that are as small as possible but still look good.

• Many photos can sustain quite a bit of compression while still maintaining image integrity.

Page 14: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

14

Principles of Web Design Chapter 7

Page 15: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

15

Principles of Web Design Chapter 7

PNG Format• A royalty-free file format that is intended to

replace GIF• This lossless format compresses 8-bit images

to smaller file sizes than GIF• PNG supports transparency and interlacing

but not animation

Page 16: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

16

Principles of Web Design Chapter 7

Interlacing & Progressive Display• Most Web-capable graphics editors let you

save images in an interlaced or progressive format.

• You can choose this display option when creating GIF, PNG, and JPG files.

• GIF and PNG files use interlacing, while JPGs use progression.

Page 17: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

17

Principles of Web Design Chapter 7

Interlacing & Progressive Display• Interlacing and progressive display are

generally the same thing—the gradual display of a graphic in a series of passes as the data arrives in the browser.

Page 18: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

18

Principles of Web Design Chapter 7

Page 19: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

19

Principles of Web Design Chapter 7

Where You Can Find Images• Stock photo collections• Digital Cameras• Scanner• Public-domain Web sites• Clip art• Create your own• Remember to respect copyright laws!

Page 20: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

20

Principles of Web Design Chapter 7

Which format?• GIF: The everyday file format for all types of

simple colored graphics and line art. Use GIF sparingly for its animation capabilities to add visual interest to your pages. GIF’s transparency feature lets you seamlessly integrate graphics into your Web site.

• JPG: Use JPG for all 24-bit full color photographic images, as well as more complicated graphics that contain color gradients, shadows, and feathering.

Page 21: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

21

Principles of Web Design Chapter 7

Which format?• PNG: If the browsers are supporting it, use

PNG as a substitute for GIF. Because PNG doesn’t compress your 24-bit images as well as JPG, don’t use it for photos.

Page 22: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

22

Principles of Web Design Chapter 7

Color Depth• The amount of data used to create color on a

display is called the color depth.• If your users have a 24-bit color display, they

can appreciate the full-color depth of your images. But many monitors cannot display 24-bit images.

• If your monitor doesn’t support the full color depth of an image, the browser must resort to mixing colors that attempt to match the original colors in the image.

Page 23: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

23

Principles of Web Design Chapter 7

Page 24: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

24

Principles of Web Design Chapter 7

Using the <IMG> element

• By definition, <IMG> is a replaced element, meaning that the browser replaces the <IMG> element with the image file referenced in the SRC attribute.

• <IMG> is an empty element, so never use a closing tag with it.

Page 25: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

25

Principles of Web Design Chapter 7

Using the <IMG> element

• The browser treats the image as it treats a character: normal image alignment is to the baseline of the text. Images that are within a line of text must have spaces on both sides, or the text will touch the image.

Page 26: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

26

Principles of Web Design Chapter 7

Page 27: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

27

Principles of Web Design Chapter 7

Specifying ALT text

• The ALT text is displayed if the image does not appear, providing a description of the image.

• In both Internet Explorer 4.0/5.0 and Netscape 4.0, the ALT text also appears as a pop-up when the user places the cursor over the image.

Page 28: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

28

Principles of Web Design Chapter 7

Page 29: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

29

Principles of Web Design Chapter 7

Specifying WIDTH and HEIGHT

• Every <IMG> element on your site should contain width and height attributes.

• These attributes provide important information to the browser by specifying the amount of space to reserve for the image.

• This information dramatically affects the way the your pages download to the user, especially at slower connection speeds.

Page 30: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

30

Principles of Web Design Chapter 7

Page 31: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

31

Principles of Web Design Chapter 7

Page 32: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

32

Principles of Web Design Chapter 7

Page 33: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

33

Principles of Web Design Chapter 7

Sizing Graphics for the Page

• One of the easiest ways to make your graphics download quickly is to keep their dimensions small and appropriate to the size of the page.

Page 34: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

34

Principles of Web Design Chapter 7

Page 35: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

35

Principles of Web Design Chapter 7

Removing the Hypertext Border

• When you create a hypertext image, the browser’s default behavior is to display the hypertext border around the image

• This border is often unnecessary as users often use their mouse to point to each image to see if the hypertext cursor displays

• To remove the hypertext border, add the BORDER=0 attribute to your <IMG> tag

Page 36: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

36

Principles of Web Design Chapter 7

Page 37: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

37

Principles of Web Design Chapter 7

Aligning Text and Images

• You can align text along an image border using the ALIGN attribute

• Text and image alignment defaults to bottom alignment, which means the bottom of the text aligns with the bottom edge of the image

• To remove the hypertext border, add the BORDER=0 attribute to your <IMG> tag

• Valid values are: top, middle, bottom, left, right

Page 38: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

38

Principles of Web Design Chapter 7

Page 39: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

39

Principles of Web Design Chapter 7

Page 40: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

40

Principles of Web Design Chapter 7

Adding White Space

• Add white space around your images to reduce clutter and improve readability

• To increase the white space around an image, you can add the VSPACE and HSPACE attributes to the <IMG> element, and set the values to a pixel amount

Page 41: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

41

Principles of Web Design Chapter 7

Page 42: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

42

Principles of Web Design Chapter 7

Page 43: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

43

Principles of Web Design Chapter 7

Using Transparent Spacer GIFs

• The transparent pixel GIF can solve spacing problems that cannot be solved with standard HTML

• You can use the WIDTH and HEIGHT attributes to change the spacer to any size you desire

Page 44: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

44

Principles of Web Design Chapter 7

Page 45: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

45

Principles of Web Design Chapter 7

Using Single-Pixel Rules• Single-pixel lines or rules work exactly like

transparent pixel GIFs, except they are a single color rather than transparent

• You can change a single-pixel rule to any size by using the WIDTH and HEIGHT attributes

• This creates reusable graphics of horizontal or vertical lines of varying thickness that you can use in many ways in your Web pages to enhance your layout

Page 46: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

46

Principles of Web Design Chapter 7

Page 47: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

47

Principles of Web Design Chapter 7

Using Background Images• You can use the BACKGROUND attribute to

the <BODY> element to tile images across the background of a Web page.

• You can use any image as a background graphic, though many are not appropriate for the task. In too many Web sites, complicated background graphics distract the user.

• If your site includes a lot of text, avoid dark or overly complex backgrounds.

Page 48: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

48

Principles of Web Design Chapter 7

Page 49: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

49

Principles of Web Design Chapter 7

Page 50: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

50

Principles of Web Design Chapter 7

Page 51: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

51

Principles of Web Design Chapter 7

CSS Background Properties• Cascading Style Sheets allow you more

control over background image tiling than standard HTML

• To apply a background image, use the <BODY> element as the selector with the BACKGROUND property

• The CSS BACKGROUND-REPEAT property allows you to create a single column or row of the image, rather than tiling completely across the page

Page 52: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

52

Principles of Web Design Chapter 7

Page 53: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

53

Principles of Web Design Chapter 7

Page 54: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

54

Principles of Web Design Chapter 7

Page 55: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

55

Principles of Web Design Chapter 7

Hexadecimal Colors• HTML uses hexadecimal numbers to express

RGB color values • Hexadecimal numbers are a base-16

numbering system, so the numbers run from 0 through 9 and then A through F

• Hexadecimal color values are six-digit numbers; the first two define the red value, the second two define the green, and the third two define the blue

Page 56: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

56

Principles of Web Design Chapter 7

Hexadecimal Colors• Browser safe hexadecimal colors are always

made up of the following 2-digit color values: 00, 33, 66, 99, CC and FF

Page 57: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

57

Principles of Web Design Chapter 7

Using Background Colors

• One of the simplest ways to work with hexadecimal color is to specify a background color for your pages.

• Use the BGCOLOR attribute in the <BODY> element, or with Cascading Style Sheets, use the BACKGROUND-COLOR property with BODY as the selector.

Page 58: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

58

Principles of Web Design Chapter 7

Using Background Colors• You can use background color in tables for

different purposes by using the BGCOLOR attribute.

• The table <TABLE>, table row <TR>, table header <TH>, and table data <TD> elements all accept the BGCOLOR attribute.

Page 59: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

59

Principles of Web Design Chapter 7

Page 60: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

60

Principles of Web Design Chapter 7

Page 61: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

61

Principles of Web Design Chapter 7

Page 62: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

62

Principles of Web Design Chapter 7

Summary• Remember that the final destination is the

monitor, not the printed page, so design accordingly.

• Most monitors have a resolution of 72 dpi. If you are creating or scanning images, or when you import images from CD-ROM, always change the final resolution to 72 dpi.

Page 63: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

63

Principles of Web Design Chapter 7

Summary• Reduce image size to the appropriate

dimensions for a Web page. If you must use a larger image, let the user view a thumbnail first, and provide the file size information.

• Use the cache by reusing graphics as much as possible.

Page 64: Chapter 7 Graphics and Color. 2 Principles of Web Design Chapter 7 Objectives Understand the differences between the Web-based image file formats - GIF,

64

Principles of Web Design Chapter 7

Summary• Work with a limited Web-safe palette when

creating graphics.• Test your work! Browsers and computing

platforms render colors differently. You should test at different color depths as well.