The HTML IMG tag is used to display the image on the web page. The HTML IMG tag is an empty tag with only features, closing tags are not used in the HTML image element.
Syntax -
<img src="path" alt="Good Morning Friends"/>
Example -
<img src="http://www.tizag.com/pics/htmlT/sunset.gif" />
Local URLs Explained:
Local Src | Location Description |
src="sunset.gif" | picture file resides in same directory as .html file |
src="pics/sunset.gif" | picture file resides in the pics directory |
src="../sunset.gif" | picture resides one folder "up" from the .html file |
src="../pics/sunset.gif" | picture file resides in the pics directory, one folder "up" from the .html file. |
Example -
<table height='200' width='400'>
<tr>
<td>
<img src="sunset.gif" height="100%" width="100%">
</td>
</tr>
</table>
Attributes of HTML img tag
The src and alt are important attributes of HTML img tag. All attributes of HTML image tag are given below.
1) src
This is an essential feature that describes the source or path of the image. It gives the browser instructions on where to show the image on the server.
The location of the image can be on the same directory or other server
2) alt
Alt attributes define alternative text for image, if it can not be displayed. The value of the Alt attribute describes the image in words. Alt attribute is considered to be good for SEO potential
3) width
This is an optional feature, which is used to specify the width to display the image. Now it is not recommended that you should implement CSS instead of the width attribute.
4) height
This specifies the height of the image. HTML height attributes also support iframe, image and object elements. Now it is not recommended that you implement css instead of the altitude attribute.
0 comments:
Post a Comment