HTML Image Tag

HTML Image Tag

ยท

1 min read

Table of contents

  • The HTML <img> tag is used to insert an image or link to a webpage. It has attributes such as src for the source of the image and alt for alternative text. The alt attribute is used when the internet connection is slow or there is an error in the src, as it will display the text of the image. Later, we can add additional attributes such as height and width to the image.

  • To insert or link an image to the webpage, there are 2 types.

    • Providing the complete URL or path to a file on the internet.

    • Providing the file path relative to the current webpage file's location.

Syntax of the image

  • complete URL or path to a file on the internet.
<!-- Image with src, alt, height and width attribute-->
    <img
      src="https://a.travel-assets.com/findyours-php/viewfinder/images/res70/68000/68045-Hyderabad-And-Vicinity.jpg"
      alt="Hyderabad"
      width="50%"
      height="60%"
    />

  • file path relative to the current webpage file's location.
<!-- Image with src, alt, height and width attribute-->
    <img
      src="charminar.jpg"
      alt="Hyderabad"
      width="50%"
      height="60%"
    />


Happy Learning

Thanks For Reading! :)

-SriParthu๐Ÿ’๐Ÿ’ฅ

ย