What is HTML Image Element?
In HTML, <img>
represents HTML image element. It is used to embed images in a webpage.
It allows to display graphics on a webpage by referencing the image source file using the src
attribute.
Example of Embedding HTML Image
Create an HTML <img>
element.
Add src
attribute to the image element.
Specify the URL or source file path of the image in the src
attribute. In this case, the address is "logoimage.jpg".
Add alt
attribute to the image element. alt
attribute provides alternative text for the image. This text is displayed if the image cannot be loaded. "xFactor School Logo" is added as alternative text.
Look at the following example:
Example of HTML Image Element
xxxxxxxxxx
<h4>Example of Image in a Webpage</h4>
<hr/>
<img src="logoimage.jpg" alt="xFactor School Logo"/>
<p> <img/> tag is used to add image in a page </p>
<p> src="logoimage.jpg" is source path of the image </p>
Output of the above example
Example of Image in a Webpage
<img/> tag is used to add image in a page
src="logoimage.jpg" is source path of the image
Here is another example of image element with abosolute URL (the complete web address or path to a resource):
"https://xfactorschool.com/logoimage.jpg"
is the absolute source path of the image
xxxxxxxxxx
<h41>Example of Image in a Webpage</h41>
<hr/>
<img src="https://xfactorschool.com/logoimage.jpg" alt="xFactor School Logo"/>
<p> <img/> tag is used to add image in a page </p>
<p> "https://xfactorschool.com/logoimage.jpg" is the absolute source path of the image </p>