In HTML, you can add images in a webpage using the <img>
tag. The <img>
is an empty tag which means it does not have a closing tag. This tag requires some set of attributes to specify the size, alignment, and other properties of an image.
Attributes are properties that you want to set for an element. Some of the commonly used attributes for <img>
element are mentioned below:
src
: short for “source”, this attribute specifies the path where the source (image) is locatedalt
: short for “alternate”, this optional attribute is used to specify alternate text in case the image does not appearwidth
: specifies the width of the imageheight
: specifies the height of the imagealign
: specifies the alignment of the image. Possible values could be left, right, center etc. By default, it is set as left.
Here’s the syntax to embed an image in an HTML web page:
<img src = "Image_URL/PATH">
Here’s an example that inserts an image at the right with width and height equal to 150px
.