Menu
HTML Images
The <img> tag is used to insert an image into an HTML document. The filename of the image source is specified in the “src” attribute. See the syntax below:
<img src="abc.jpg">
Example:
HTML images also have “width” and “height” attributes, which specifies the width and height of the image. See the code snippet below:
<img src="abc.jpg" width="500" height="600">
See more coding examples below.
Example 5 [Working with images using “img” tag]:-
<html>
<body>
<p>
A static image:
<img src="static.gif" width="144" height="50">
</p>
<p>
A moving image:
<img src="moving.gif" width="48" height="48">
</p>
<p>
Note that the syntax of inserting a moving image is no different from that of a non-moving image.
</p>
</body>
</html>
Output:
Example 6 [Setting background with images]:-
<html>
<body background="bgdesert.jpg">
<b>
<p>A Background Image</p>
<p>Both GIF and JPG files can be used as HTML backgrounds.</p>
<p>For images which are smaller than the web page will repeat themselves.</p>
</b>
</body>
</html>
Output: