How to add images in HTML

In HTML, img tag is used to add images. This is not a tag that is opened and closed, because it does not have a closing tag.

It is used as <img src=”” alt=””>

Features of the HTML img tag

  • width, height, src, and alt are the features of img tag.
  • width attribute is used to determine the width of the image.
  • height attribute is used to determine the height of the image.
  • src attribute is used to determine the address/path of the image.
  • alt attribute is used to define an alternate text for the image. If there is no source for the image (if the src part is empty), the text we wrote appears in the lower part.

HTML Adding Image

<img src="http://via.placeholder.com/100x100" alt="">

img alt attribute

As shown in the example below, when the image path (src) is faulty (when the image path cannot be reached) or when the image path is empty, the text we wrote within alt parameter appears on the screen.

<img src="" alt="HTML Image tag">
HTML Image tag

img width attribute

<img src="http://via.placeholder.com/100x100" alt="" width="50">

img height attribute

<img src="http://via.placeholder.com/100x100" alt="" height="50">
257 Views
79720cookie-checkHow to add images in HTML

Leave a Reply

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