Using images In HTML/How to Insert an Image in a Webpage



A web page may contain different types of graphics. Graphics make website more attractive and more interesting. HTML can be used to add static or animated graphics to the website. The image put on the web page is called inline images. The most popular type of images used in web pages are .GIF and .JPG.
<IMG> Tag is used to insert image in the web page. This <IMG> Tag has no ending tag.

Attributes

Some important attributes of <IMG> Tag are as follow.

SRC

It specifies the name and path of image to be displayed. Only name of names is specified if images is stored in the same directory in which web page is stored. Otherwise complete path of the image is specified.

ALING

It specifies the alignment of the image. Possible alignments are as follow.
Left The image is aligned to Left on the screen.
Right The image is aligned to Right on the screen.
Center The image is aligned to Center on the screen.
It also specifies the text alignment with respect to the image. Possible alignments are as follow.
Top The text is written at the top next to the image.
Bottom The text is written at the bottom next to the image.
Middle The text is writtenat the middle next to the image.

BORDER

It specifies the size of border around the image. The possible values are 1, 2, 3 and so on. The default value is 0.

WIDTH

It specifies the width of image in pixels.

HEIGHT

It specifies the height of image in pixels.

HSPACE

It specifies amount of space to left and right side of image in pixels.

VSPACE

It specifies the amount of space to top and bottom of image in pixels.

ALT

It specifies the text to be displayed if he browser can not display image.

Example Of Using images In HTML

<IMG SRC="Pic.JPG" Align="center" Border="2">

The above example display "pic.jpg" image in the center of the page with the border of  size 2 around it.

<IMG SRC="Pic.JPG" Align="right" ALT="image not found">

The above example display "Pic.jpg" image in the right of the web page. If the browser can not display the image, the text "image not found" will be displayed.