Last Updated on April 26, 2023 by Roshan Parihar
Learn how to add images in webpages using HTML image tag. You can display images content by adding the URL of the image in <img> tag.
There are two attributes of the tag to add images with alt text. These are src
and alt
HTML attributes to specify the images.
The alt
attribute can be used to add alternate text to show. The alternate text will appear only when the image URL or the media is not available.
Syntax
1 |
<img src="enter URL of the image here" alt="put an alternate text here"/> |
Example
1 |
<img src="../images/nature.jpg" alt="HTML image"/> |
Output
List of HTML image tag attributes
Sr. No. | image attributes | Description |
---|---|---|
1 | src | Used to get the url location of the image from where we get the image. |
2 | alt | Used to show the alternative text when the server not able to find the image in the given location. |
3 | width | Used to define the width of the image. |
4 | height | Used to define the height of the image. |
Resources and References
1. W3C Specification.
2. HTML living standard
3. W3C project using Github