Html Tutorial


To make a beautiful website images play an important role, as you can display complex things from a picture easily.

Inserting an image

To insert an image in HTML document <img> tag is used.

img tag does not have any closing tag. It has only attributes.


<h3>Inserting Image</h3>
<img src="images/demo1.jpg" alt="demo image" width="300px" height="200px" border="5" />


Inserting Image

demo image

Attributes in img tag

1. src attribute

This attribute describe the path or source of an image. As in above example you can see the source is "images/demo1.jpg".

2. alt attribute

Sometimes images are unable to load so the text inside the alt attribute replaces the image.

3. width attribute

width attribute is used to define widtn for image.

4. height attribute

height attribute is used to define height for image.

If width and height attributes are not mentioned then image will be of its original size.

5. border attribute

border attribute is used to give a border to the image. More the value for border more wide border is made.