is the ability of the Web to provide pictures, technically called images, graphics, pictures
or sometimes icons, that have made it so popular. By adding images to the web pages,
it will add better look and feel as well as complete information about the topic by text
and by visuals. In section, you’ll learn how to place an image on your page and also
how to turn an image into a link to another page.
There are two basic image file formats you will find on the Web. Each is
denoted to the browser by a different suffix. GIF is an acronym for Graphics
Interchange Format and JPEG or JPG (pronounced “j-peg”) are two names to denote
the other format. JPEG is an acronym for Joint Photographic Experts Group, the
organization that invented the format.
GIF format was invented by Compuserve and it’s very popular. The reason is
that it’s a simple format. It’s a series of coloured picture elements, or dots, known as
pixels, that line up to make a picture.
The JPEG format is unique in that it uses compression after it has been created.
For example, if the picture is 10K bytes when displayed, it may be only 4K bytes
when stored.
Let’s start this section with an image of the Sinharaja Rainforest, which has
been stored in your computer hard disk. The name of the image file is 'Sinharaja. jpg.'
Including images is very simple. You employ the <IMG> (for IMAGE) tag. The required
attribute of this tag is SRC, which takes the value of the image file’s URL For example:
<IMG SRC=”Sinharaja.jpg”>
Example 5.9
<HTML>
<HEAD>
<TITLE>Example 5.09</TITLE>
</HEAD>
<BODY>
<H1>Inserting Image</H1>
<P>Sinharaja Rainforest<BR>
<IMG SRC=”Sinharaja.jpg” ALT=”Sinharaja
Forest”>
<P>Sinharaja is the country’s last viable area of
primary tropical rainforest. More than 60% of the trees
are endemic and many of them are considered rare. There
is much endemic wildlife, especially birds, but the reserve
is also home to over 50% of Sri Lanka’s endemic species
of mammals and butterflies. As well as many kinds of
insects, reptiles and rare amphibians. </P>
</BODY>
</HTML>
The SRC attribute determines the source of the image file and takes a URL as
value. We have used a relative URL which shows that 'Sinharaja.jpg' is located in the
same directory as this file or another web site with its location. For example if the
'Sinharaja .jpg' image is located in the web address of www.ucsc.cmb.ac.lk, it can be
inserted as follows.
<IMG SRC=”http://www.ucsc.cmb.ac.lk / Sinharaja.jpg”>
Picture of Sinharaja in the Web Page
Alternative Images
The <ALT> (ALTernate image) attribute is now required. You can put some
advisory text with the use of this attribute. This text is displayed when the mouse
pointer is placed on the image. You should get into the good habit of including ALT
tags. Visitors using text-based browsers or who have turned off images in their browsers
will not be able to see the image. However, they would be able to read the image
description through the ALT attribute.
<IMG SRC=”Sinharaja.jpg” ALT = “Image of Sinharaja Rainforest”>
advisory text with the use of this attribute. This text is displayed when the mouse
pointer is placed on the image. You should get into the good habit of including ALT
tags. Visitors using text-based browsers or who have turned off images in their browsers
will not be able to see the image. However, they would be able to read the image
description through the ALT attribute.
<IMG SRC=”Sinharaja.jpg” ALT = “Image of Sinharaja Rainforest”>
Aligning Text & Images
Image can be place at a specified position, in relation to the paragraph. In this
case few attributes can be used like in Figure 5.10, such as 'ALIGN' and 'WIDTH'.
case few attributes can be used like in Figure 5.10, such as 'ALIGN' and 'WIDTH'.
Example
<HTML>
<HEAD>
<TITLE>Example 5.10</TITLE>
</HEAD>
<BODY>
<H1>Aligning Text & Images</H1>
<P> The text aligns with the top of the
image.</p>
<IMG ALT=”Galle Port” ALIGN=TOP WIDTH=360
SRC=”Galle Port.jpg”>
<H2><FONT SIZE=6><B> Galle Port <B>
</FONT></H2>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Example 5.10</TITLE>
</HEAD>
<BODY>
<H1>Aligning Text & Images</H1>
<P> The text aligns with the top of the
image.</p>
<IMG ALT=”Galle Port” ALIGN=TOP WIDTH=360
SRC=”Galle Port.jpg”>
<H2><FONT SIZE=6><B> Galle Port <B>
</FONT></H2>
</BODY>
</HTML>
Alignment
The ALIGN attribute is used to align other HTML elements such as text around
the image. Thus, <IMG SRC="Galle Port .jpg" WIDTH="360" ALIGN="TOP"> will
align the image to the top and text to its bottom.
<IMG ALIGN=TOP SRC=”image.gif”>
ALIGN can also take “TOP”, “BOTTOM” or “MIDDLE” as value. These
align the text to the top, middle or bottom of the image.
the image. Thus, <IMG SRC="Galle Port .jpg" WIDTH="360" ALIGN="TOP"> will
align the image to the top and text to its bottom.
<IMG ALIGN=TOP SRC=”image.gif”>
ALIGN can also take “TOP”, “BOTTOM” or “MIDDLE” as value. These
align the text to the top, middle or bottom of the image.
TOP The text aligns with the top of image
TEXTTOP The image is aligned with the top of the
tallest text in the line.
MIDDLE The text aligns with the middle of the
image
BOTTOM The text aligns with the bottom of the
image
LEFT The image aligns with the left margin,
and the text wraps around the right.
RIGHT The image aligns with the right margin,
and the text wraps around the left.
TEXTTOP The image is aligned with the top of the
tallest text in the line.
MIDDLE The text aligns with the middle of the
image
BOTTOM The text aligns with the bottom of the
image
LEFT The image aligns with the left margin,
and the text wraps around the right.
RIGHT The image aligns with the right margin,
and the text wraps around the left.
No comments:
Post a Comment