Lesson 25 CS
Lesson 25 CS
25
In the previous lesson you have learnt how to create web pages with formatted
text. You know that web pages also contain images. Images make a web page
more colorful and interesting. If a web page contains text only then most of
the people may not like to read it completely. A page becomes more interesting
and attractive if it contains images to illustrate some concepts or just to show
the images of some events or personalities. In this lesson you will learn how
to insert images in a web page.
OBJECTIVES
After reading this lesson, you will be able to:
identify image files by their file name extension;
insert images in a web page;
format images and text on a web page.
Notes
One <IMG> tag inserts one image in the web page. By using multiple <IMG>
tags we can insert multiple images. Now let us see how various tags affect the
appearance of an image.
Let us now see the effect of various attributes of <IMG> tag.
The HEIGHT and WIDTH attributes are used to specify the height and width
both (in pixels) of the image to be displayed. If the size (height and width) of
an image is not as per the requirements of a web page, we specify the display
size of the image by using HEIGHT and WIDTH attributes of the <IMG> tag.
If these attributes are not specified then the image will be displayed in
original size.
BORDER tag is used to specify the size/width/thickness (in pixels) of the image
border. If BORDER attribute is not specified then the images will be displayed
without any border.
Sometimes, it may happen that the image to be displayed is not available or the
image cannot be displayed in the browser. In such cases, the browser places
a cross symbol (in place of the image) indicating that the image is not available
or could not be displayed. The user does not get any clue about which image
has to be displayed there. Using ALT attribute we can specify the alternate text
to be displayed if the image is not available or cannot be displayed.
Notes
These four images, numbered 1,2,3, and 4, are due to statements numbered 7,
8, 9, and 10 respectively. You can easily observe the effect of various attributes.
Notice URL of the image in this example. The URL “images\Tejas.jpg” specifies
that the image file, Tejas.jpg, lies in the sub-folder images of the current folder.
ALIGN Attribute
ALIGN attribute of <IMG> tag specifies the alignment of the image according
to surrounding elements. Different possible values of ALIGN attribute and their
effects are given in the following table:
value of ALIGN
attribute Effect
Left Place the image at the left-most possible space in the window and
wrap the other contents around the right hand side of that image.
Right Place the image to the right-most possible space in the window.
Top Aligns the top of the image with the top of the current line.
Middle Aligns the middle of the image with the baseline of the current line.
Bottom Aligns the bottom of the image with the baseline of the current line.
Notes
Notes b. ........................... file format is the best option for images with a few
colors such as logos, pencil drawings etc.
c. ........................... file format is the best option for images with
transparency effects.
d. ........................... tag is used to insert an image in a web page.
e. BORDER attribute of <IMG> tag specifies the border width in
............................
2. State whether the following statements are ture or false:
a. <IMG> tag has a corresponding </IMG> tag.
b. Using ALIGN attribute of <IMG> tag we can place an image in the
center of the browser window.
c. ALIGN = TOP places an image at the top of the browser window.
d. Using SRC attribute of <IMG> tag, we specify the URL of the image
to be displayed.
e. BORDER attribute is used to specify border color of the image.
This is a part of an HTML document to show the unordered list only and will
generate the following list:
Agricultural Aircraft
Fighter Aircrafts
Fighter Aircrafts
Helicopters
Engines
Trainer Aircrafts
Observation Aircrafts
Transport Aircrafts
The shape of the bullets in a bulleted list can be changed by using the TYPE
attribute of <UL> tag as shown in the following table:
Ordered Lists
An ordered list is a list in which elements are given sequence numbers. Such
lists are generally created when order of elements in the list is important. An
ordered list is created using <OL> tag in the HTML code. Different items in
the list are inserted using <LI> tag as in an unordered list. An example of an
ordered list is given below:
<OL>
1. Agricultural Aircraft
<LI>Agricultural Aircraft </LI>
<LI>Fighter Aircrafts </LI>
2. Fighter Aircrafts
We can also start the ordered list with a number other than 1 using START
attribute of <OL> tag. START attribute can take any integer value with which
we want to start the list. Two examples of lists with START attributes are given
below.
<OL START = 4> <OL Type = A START = 6>
4. Agricultural Aircraft F. Agricultural Aircraft
5. Fighter Aircrafts G. Fighter Aircrafts
6. Fighter Aircrafts H. Fighter Aircrafts
7. Helicopters I. Helicopters
8. Engines J. Engines
9. Trainer Aircrafts K. Trainer Aircrafts
10. Observation Aircrafts L. Observation Aircrafts
11. Transport Aircrafts M. Transport Aircrafts
Notice that START takes an integer value irrespective of the TYPE attribute.
Nesting of lists
In HTML we can nest lists into one another upto any level. An example of a
nested list is given below:
Like this we can nest any list (Unordered, Ordered, Definition) in any other
(Unordered, Ordered, Definition).
Notes
Notes
TERMINAL EXERCISE
1. Name any five digital file formats.
2. When are the following file formats suitable:
JPG, GIF, PNG.
25.1
1. a) JPEG b) GIF c) PNG d) <IMG> e) Pixels
2. a) False b) False c) True d) True e) False
25.2
1. a) Ordered List b) <UL> c) <LI> d) 1 e) TYPE
2 a) False b) True c) True d) False e) True