Attributes
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.
<img src="picture1.jpg">
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.
<img src="picture1.jpg" width=200 height=100>
<img src="picture1.jpg" width=60% height=20%>
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.
<img src="picture1.jpg" alt="Here is your alternate text">
If the browser can ‘ t find the image, then it will show the alternate text.
Display an Image with attributes
HTML Source Code :
<html>
<body >
<img src="http://www.corelangs.com/logo.png" width=227 height=131 alt="Logo Picture">
</body>
</html>