IMG Tag HTML

 IMG- By using IMG tag and its SRC attribute we can add picture into our HTML document. It is empty tag.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC ="1.jpg">
</BODY>
</HTML>

Attributes of IMG Tag
  • Src
  • Width
  • Heigh
  • Alt
  • Align 
SRC (Source)- Using SRC attribute of IMG tag we can specify the source of image file.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC="1.jpg">
</BODY>
</HTML>

WIDTH- Using Width attribute of IMG tag we can specify the width of image file.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC="1.jpg" width=50%>
</BODY>
</HTML>

HEIGHT- Using Height attribute of IMG tag we can specify the height of image file.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC="1.jpg" height=50%>
</BODY>
</HTML>

ALT- If image display is not possible or disabled by the user then Alt attribute of IMG tag is used to specify alternate text for image information.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC="1.jpg" alt="Picture of Flower">
</BODY>
</HTML>

ALIGN- Using Align attribute we can align image using 5 values of Align attribute LEFT, RIGHT, TOP, BOTTOM, MIDDLE, MIDDLE.

<HTML>
<HEAD>
<TITLE>
Title of the document
</TITLE>
</HEAD>
<BODY>
<IMG SRC="1.jpg" align=left><br>
<IMG SRC="1.jpg" align=right><br>
<IMG SRC="1.jpg" align=top><br>
<IMG SRC="1.jpg" align=bottom><br>
<IMG SRC="1.jpg" align=middle>
</BODY>
</HTML>