How To Use Image In HTML?

HTML img tag is used to show image on the web page. We can insert image by using HTML img tag, closing tags are not used in HTML image element.

Below is the example of HTML image.

<h2>HTML Image Example</h2>
<img src="india_gate.jpg" alt="India Gate" />

Output

India-Gate

 

Image Src
It is a important attribute that represent the source of the image. It tells the browser where is the image on the server. We can use image source from same directory or can use external source through image link.

 

Image Alt
The alt attribute defines an alternate text for the image, It is very important for SEO prospective because google can not read image, so alt tells google what kind of image it is. In other way alt attribute describe the image in words.

 

Image Width
It is an optional attribute which is used to specify the width to display the image. It is not recommended now. You should apply CSS in place of width attribute.

 

Image Height
We can define height of the image. The HTML height attribute also supports iframe, image and object elements. It is not recommended now. We can apply CSS in place of height attribute.

 

Supporting Browsers

Element  Chrome  Firefox  Opera  Safari  IE
<img> Yes Yes Yes Yes Yes

Leave a Reply

Your email address will not be published. Required fields are marked *