images (1) three most popular formats – graphics interchange format (gif) – joint photographic...

Post on 29-Dec-2015

219 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Images (1)

• Three most popular formats– Graphics Interchange Format (GIF)– Joint Photographic Experts Group (JPEG)– Portable Network Graphics (PNG)– img element with attributes:

• src attribute : Specifies the location of the image file• width and height attributes: Pixels (“picture elements”)• alt attribute : the text will be displayed if the browser could not display

the image.

• HTML The <img> Tag and the Src Attribute• Syntax for defining an image:• <img src="url" alt="some_text"/>• <img src="boat.gif" alt="Big Boat" />

Insert an image from another folder or another server

Align an image within the text

Use an image as a link.

Creating and Using Image Maps (1)

• Designate certain areas of an image (called hotspots) as links– Element map• Attribute id identifies the image map

– Element img • Attribute usemap refers the map by id.

– Example: <map id=“picOne”> .. </map><img src=“picture.gif” usemap=“#picOne” />

Creating and Using Image Maps (2)

• Element area defines hotspot– Attribute shape and coords• Specify the hotspot’s shape and coordinates• Rectangular ( shape = “rect” )• Polygon ( shape = “poly” )• Circle ( shape = “circle” )

– Attribute href • Specifies the link’s target.

– Attribute alt • Provides alternative text for the link.

To create an image map, with clickable regions. Each of the regions is a hyperlink

----------------------------

1 <?xml version = "1.0" ?>

2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

4

5 <!-- Fig. 5.7: picture.html -->

6 <!-- Creating and Using Image Maps -->

7

8 <html xmlns = "http://www.w3.org/1999/xhtml">

9 <head>

10 <title>

11 Internet and WWW How to Program - Image Map

12 </title>

13 </head>

14

15 <body>

16

17 <p>

18

19 <!-- the <map> tag defines an image map -->

20 <map id = "picture">

21

22 <!-- shape = "rect" indicates a rectangular -->

23 <!-- area, with coordinates for the upper-left -->

24 <!-- and lower-right corners -->

25 <area href = "form.html" shape = "rect"

26 coords = "2,123,54,143"

27 alt = "Go to the feedback form" />

28 <area href = "contact.html" shape = "rect"

29 coords = "126,122,198,143"

30 alt = "Go to the contact page" />

31 <area href = "main.html" shape = "rect"

32 coords = "3,7,61,25" alt = "Go to the homepage" />

33 <area href = "links.html" shape = "rect"

34 coords = "168,5,197,25"

35 alt = "Go to the links page" />

36

37 <!-- value "poly" creates a hotspot in the shape -->

38 <!-- of a polygon, defined by coords -->

39 <area shape = "poly" alt = "E-mail the Deitels"

40 coords = "162,25,154,39,158,54,169,51,183,39,161,26"

41 href = "mailto:deitel@deitel.com" />

42

43 <!-- shape = "circle" indicates a circular -->

44 <!-- area with the given center and radius -->

45 <area href = "mailto:deitel@deitel.com"

46 shape = "circle" coords = "100,36,33"

47 alt = "E-mail the Deitels" />

48 </map>

49

50 <!-- <img src =... usemap = "#id"> indicates that the -->

51 <!-- specified image map is used with this image -->

52 <img src = "deitel.gif" width = "200" height = "144"

53 alt = "Deitel logo" usemap = "#picture" />

54 </p>

55 </body>

56 </html>

add style information into the <head> section

External Style Sheetuse the <link> tag to link to an external style sheet

• An external style sheet is ideal when the style is applied to many pages.

• With an external style sheet, you can change the look of an entire Web site by changing one file.

• Each page must link to the style sheet using the <link> tag.

• The <link> tag goes inside the <head> section:<head><link rel="stylesheet" type="text/css" href="mystyle.css" /></head>

Internal Style Sheet• An internal style sheet can be used if one single document

has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this:

• <head><style type="text/css">body {background-color:yellow}p {color:blue}</style>

</head>

Inline Styles• An inline style can be used if a unique style is to be applied to

one single occurrence of an element.• To use inline styles, use the style attribute in the relevant tag.

The style attribute can contain any CSS property. The example below shows how to change the text color and the left margin of a paragraph:

• <p style="color:blue;margin-left:20px">This is a paragraph.</p>

top related