HTML Image Element
Img tag is used to display image inside webpage. Almost every webpage display one or images because this plays an important role for readers attention. We can also use images as buttons for beautiful and attractive interfaces.
Img Attributes
In HTML image element has some specific attributes that only used within img tag. Except these attributes we can also use common attributes such as title, class, id and style. The tag specific attributes are.
- Src Attribute
- Alt Attribute
- Width & Height Attribute
Img Src
Source attribute hold the address of image to be displayed. This is complete address with image type / extension. Image source value maybe absolute or relative.
Absolute img src
If we are using absolute src value then there will be exact and complete path of the image. Which consists of root directory and complete folder path.
Example
<img src="https://www.abc.com/images/image.jpg" />
Relative img src
Alternatively HTML also support relative path of the image. In this case only image name is used or possibly with minimum folder names. If only name is used inside src value then browser look for this image in current directory. It is recomended to use relative image source.
Example
<img src="image.jpg" />
Img Height & Width
It is recomended that we must have to specify height and width, so that the content of page never mesh up on different screen resolutions.