Table of contents
The HTML
<img>
tag is used to insert an image or link to a webpage. It has attributes such assrc
for the source of the image andalt
for alternative text. Thealt
attribute is used when the internet connection is slow or there is an error in thesrc
, as it will display the text of the image. Later, we can add additional attributes such asheight
andwidth
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๐๐ฅ
ย