The HTML < img > tag is used for embedding images into an HTML document. Image tag has attributes like src, width, height, alt etc.

Image Src

The Img attribute Src stands for source of your Image location, this is the path to your Image file. In order to display an image on a page, you need to use the src attribute. The value of the src attribute is the URL of the image you want to display. The src attribute ' s value can be any valid URL of an image on the Web , local or remote.

There are three image formats in constant use on the net , they are jpg, .gif and .png format.

Image Width and Height

We can define the size of an image by its Width and Height attributes. These values can either be percentage based (%) or rely on pixel sizes.

Width and Height attributes are optional, it is a good practice to specify both the height and width attributes for an Image. If no height or width attribute is specified , the browser will use the actual size of the Image file. If these attributes are set, the space required for the Image is reserved when the page is loaded in the browser.

Image Alt

Image Alt attribute specifies an alternate text for an Image. This tells the browser that if it can ' t find the Image, then just display the text value in the place of the same image in the browser.

If the browser can ' t find the image, then it will show the alternate text.

Display an Image with attributes


HTML Source Code :