HTML Image tag

Including an image in html requires use of <img> tag. To display an image we have to give image path in src attribute image path can be path of image storage in local system or it can be a url.

Syntax

img tag uses following few attributes

  1. src: This attribute is compulsory it provide path to image(including image name with extension). path may be either url or path of image in directory if image is in same directory where your htlm page is then you have to give image name with extension only.
  2. alt: It provides alter native text for image. If image is not loaded then browser will display this text message.
  3. width: We can set the width of image either in pixel value or % wise.
  4. height: We can set the height of image either in pixel value or % wise.

Tag

Example:

img with alt attribute

img with alt, width & height attribute

Output:

Image

Image

Image