HTML Images
HTML img element adds an image in a page. Firstly we write an image tag. Then, we add the src attribute in the <img> tag.
Syntax to add an image.
Example
<img src="files/logo.png" alt="codingb-logo" width="300"/>
Try </>
src attribute specifies the location (address) of the image.
Image Related Attributes
src attribute
src attribute specifies the location (address) of the image.
alt attribute
alt attribute is used to give the alternate name to an image in the form of text.
This text can be seen when an image is not available due to slow network or wrong address.
height attribute
height attribute represents the vertical dimension.
width attribute
height attribute represents the horizontal dimension.
NOTE: align attribute was used to align the image in the text but now it is obsolete. align attribute is not included in HTML5.
Tip: Always remember there is no end tag for <Img>. Therefore, only one tag is used. You can also use <img /> tag.
Next Previous
Was this article helpful?