9 Demos to Learn HTML img tag With src, alt and CSS


9 Demos to Learn HTML img tag With src, alt and CSS

9 Demos to Learn HTML img tag With src, alt and CSS

The <img> tag of HTML

The <img> tag of HTML is used to include the images in your web pages. You may specify the source of an image in the img src attribute along with alternative text in the alt attribute.

The alt attribute is useful in case image is not available or web browser is not able to pull the source image. Different kinds of images can be used in the HTML img tag e.g .jpg, .gif, .png etc.

Syntax of using the img tag

<img src=”image path” alt=”Alternative text” height=”” width=”” />

Where:

  • src: specifies the image path which is mandatory. This can be the relative or the absolute path.
  • img alt: alternative text.
  • Height and width that specify image dimensions

Note that, the <img> tag is closed by a forward slash followed by “>”. You do not need to close it like many other tags like </div>, </p> or </span>.

A few img tag examples

img src path example

img alt example

HTML image link example

CSS img src example

A Video demonstration of img tag