Page 72 - Computer - 8
P. 72
INSERTING IMAGES
Images make a web page more informative and attractive. An image can
be in the form of a graphic, clip art, photograph, or any other visual object.
The image file formats supported by most web browsers are JPEG, GIF,
and PNG.
Joint Photographic Expert Group (JPEG)
JPEG is the most used image file format to display photographs and
digital images. It is capable of displaying millions of colours at once.
JPEG images usually use a .jpg filename extension.
Graphics Interchange Format (GIF)
GIF format is used to display images created with a graphics software. GIF files have low display quality
as they support upto 256 colours only and are smaller in size. A single GIF file can also store multiple
images and display them as animation. GIF images use a .gif filename extension.
Portable Network Graphics (PNG)
PNG format is best for images with transparent backgrounds or low colour counts. At present, this
format is widely used in web pages. PNG images use a .png filename extension.
Let us learn how to insert an image in a web page.
Image <img> Tag
The Image <img> tag is used to insert images in a web page. It is an empty tag.
The attributes of the <img> tag are described in the table given below.
Attribute Description Value(s) Example
src Specifies the name of the URL of the image file <img src= “computer.jpg”>
image file
alt Specifies an alternate text for text <img src= “computer.jpg”
the image that is displayed if alt=”Computer”>
the image is not displayed
width Specifies the width of value in pixels <img src= “computer.jpg”
the image width=100>
height Specifies the height of value in pixels <img src= “computer.jpg”
the image height=”200”>
You can also position images as required on a web page, add borders and margins to them, and control
their appearance by using the CSS rules.
The CSS property float lets you float an image to the right or left of text. It takes two values – right and
left.
70