Introduction To HTML Lesson 3: Images
Introduction To HTML Lesson 3: Images
Lesson 3: Images
Lesson 3
Images
Lesson 3 - Images
32
Introduction to HTML
Lesson 3: Images
Lesson Objectives:
Images & Formats
Points to Consider
Inserting Images
Creating Images
Transparent Images
GIF Animations
Imagemaps
Lesson 3 - Images
33
Introduction to HTML
Lesson 3: Images
Getting Images
Clipart/Stock Photos - images can be
downloaded or purchased.
Graphics can be created in special graphics
programs.
Use your own original photographs.
Lesson 3 - Images
34
Introduction to HTML
Lesson 3: Images
Lesson 3 - Images
The GIF format once gained its popularity with CompuServe but it is now the
most commonly used graphic format on the web. The GIF format generally
downloads faster than others but with its limitation of 256 colors, it is not ideal for
photographs.
A GIF file can be saved as interlaced or non-interlaced. An interlace GIF allows
the browser to show a blurry version of the image as it downloads. Large images
especially should be saved as interlaced so the user has something visual to look
at while the web page is downloading.
There is an 89A version of GIF which allows the user to choose one color in the
image to be transparent. This is a very useful feature for the web as it makes an
image appear to be floating on the web.
Advantages of GIF:
Shorter download time when compared with JPEG.
No information in the graphic is lost during the compression process.
GIF files are compressed files (i.e. 256 colors).
35
Introduction to HTML
Lesson 3: Images
Lesson 3 - Images
The JPEG format is relatively new but due to its high compression rate, it is now
often preferred on the web. The name of this format is JPEG and the file
extension is .JPG. Because it supports a large number of colors, JPEG should
be used for photographs and other high resolution images. However, JPEG does
not support transparent colors.
The JPEG equivalent of an interlaced GIF is the progressive JPEG which shows
a blurry image while it is being downloaded.
Advantages of JPEG:
JPEG has 16.7 million color palette.
JPEG images are better looking because it reproduces photographic
quality.
36
Introduction to HTML
Lesson 3: Images
Points to Consider
Download time. Avoid testing the patience of
your visitors!
The file size of the image is a very important
consideration in using graphics on the web.
In general, the total size of all images on one
page should not exceed 40KB.
However,always keep the overall experience of
your audience/visitors in mind.
Lesson 3 - Images
JPEG
JPEG is able to reproduce photographic
quality.
37
Introduction to HTML
Lesson 3: Images
Inserting Images
Use the empty Image Source tag.
Syntax:
<IMG SRC=image location/path>.
Lesson 3 - Images
When using the <IMG SRC> tag, you are telling the browser where the image
can be found. If you are using a relative address, it can be written as:
images/logo.gif. If you are using an absolute address or URL (Uniform Resource
Locator), write as: http://www.mysite.com/images/logo.gif.
If you have no images, download an image from www.clipart.com and save it in a
folder entitled images and type as in the following exercise.
Practice Exercise
<BODY>
<IMGSRC=images/filename.ext><!Theextshouldbe
replacedbygiforjpgdependingontheimagebeingused.>
</BODY>
38
Introduction to HTML
Lesson 3: Images
39
Introduction to HTML
Lesson 3: Images
Attributes of <IMG>
<ALT=__>: Displays text instead of the
image until the image is loaded on the clients
computer.
<ALIGN=___>: Aligns the text that comes
after the image with the image itself. Possible
values are: Top, Bottom, Left, Right, Middle.
Lesson 3 - Images
The ALT attribute can be especially helpful for users who are surfing the web with
text-based browsers as it gives them an idea of what the image is about.
Note that the ALIGN attribute does not move the image itself. It aligns the text
that comes after the image with the image.
Practice Exercise
<BODY>
<IMGSRC=images/logo.gifALT=ABCCompanyLogo
ALIGN=Middle>
<H2>TheABCCompany...uptothetimes.</H2>
</BODY>
40
Introduction to HTML
Lesson 3: Images
Lowres Attribute
<Lowsrc=path>
Shows a low res (resolution) version of the
image while the other is downloading.
This lowres version is a separate file.
Lesson 3 - Images
With the LOWRES attribute, you can keep the user entertained while the actual
high-quality image is downloading
(To practice this, we would need two versions of the same image with different
qualities. This would have to be created in a graphics program.)
<BODY>
<IMG SRC=images/logo.gif LOWRES=images/logolow.gif>
</BODY>
41
Introduction to HTML
Lesson 3: Images
Height/Width Attributes
<Height=pixels>
<Width=pixels>
Indicate the exact size of the image.
Lesson 3 - Images
These attributes should not be used for sizing/scaling the image as they do not
affect file size, only the appearance in the browser.
Practice Exercise
Type the following and then change the values for HEIGHT and WIDTH to see its
effect.
<BODY>
<IMGSRC=images/logo.gifHEIGHT=100WIDTH=85>
</BODY>
42
Introduction to HTML
Lesson 3: Images
Border Attribute
Thickness of the border around the linked
image.
Syntax:
<Border=pixels>
Make the Border=0 if you dont want a border
around the image.
Lesson 3 - Images
The BORDER is simply a frame around the image. It is effective for certain
images.
Practice Exercise
Type the following:
<BODY>
<IMGSRC=images/logo.gifBORDER=3>
</BODY>
43
Introduction to HTML
Lesson 3: Images
Lesson 3 - Images
44
Introduction to HTML
Lesson 3: Images
Transparent GIFs
Used very commonly on the web.
The transparent images appear as though they
are floating on the page.
Are saved in the GIF 89A format which allows
you to choose one color (usually the
background color) in the image as transparent.
Paint Shop Pro, PhotoShop, etc, can be used
to create transparent GIFs.
Lesson 3 - Images
45
Introduction to HTML
Lesson 3: Images
Imagemaps
Allows you to create a graphical interface.
Helpful for navigation of the web site.
An imagemap is one single image, GIF or J PG,
with hot links for which a map is defined.
Currently a popular feature on many web sites.
Lesson 3 - Images
3.1.
46
Introduction to HTML
Lesson 3: Images
Server-Side Imagemaps
The first form of imagemaps.
The HTML code (mapping file) completely
depends on the server and must meet its
specifications.
These imagemaps put additional load on the
server.
Can only be tested once the files are loaded on
the server.
Lesson 3 - Images
47
Introduction to HTML
Lesson 3: Images
Client-Side Imagemaps
Lesson 3 - Images
48
Introduction to HTML
Lesson 3: Images
Animated GIFs
A series of images saved as one file using a
special program.
Images must be saved as GIFs.
All the images should be the same size.
Created in a standard graphics editor.
Images are put together in a program like GIF
Construction Set (shareware version available
at www.mindworkshop.com).
Lesson 3 - Images
49
Introduction to HTML
Lesson 3: Images
Summary
Libraries of clipart and photographs can be downloaded, ordered on-line, or
purchased from a retail shop.
GIF format is one of the most popular graphic formats on the web. GIF files
download fast, but have a limitation of 256 colors and thus are not suitable for
photographs.
JPEG supports up to 16.7 million colors. JPEG files are ideal for
photographs.
Transparent GIFs are very common on the web; they appear as though they
are floating on the web page. Paintshop Pro, Photoshop, etc, can be used to
create GIFs with transparent backgrounds.
An imagemap is one single image (GIF or JPEG) with hot links for which a
map is defined. Imagemaps allow you to create a graphical interface and are
helpful for navigation of a web site.
GIF animations are a series of images saved as one file. Images must be
saved as GIFs. All the images must be the same size.
50
Introduction to HTML
Lesson 3: Images
Exercises
1. What images do common browsers support?
2. Can images be hyperlinked?
3. How do you make an image as background?
4. Make a simple HTML document with an image as a background and give
<ALT> attribute to the image. Also give a heading to the page in <H1> tags.
51