
Images are very important to beautify as well as to depict many complex concepts in simple way on your web page. This tutorial will take you through simple steps to use images in your web pages.
Insert Image
You can insert any image in your web page by using-list/> Theattributes
Example
To try following example, let's keep our HTML file test.htm and image file test.png in the same directory:This will produce following result:Using Image in Webpage Simple Image Insert![]()
Simple Image Insert
You can use PNG, JPEG or GIF image file based on your comfort but make sure you specify correct image file name in src attribute. Image name is always case sensitive.
The alt attribute is a mandatory attribute which specifies an alternate text for an image, if the image cannot be displayed.
Set Image Location
Usually we keep our all the images in a separate directory. So let's keep HTML file test.htm in our home directory and create a subdirectory images inside the home directory where we will keep our image test.png.Example
Assuming our image location is "image/test.png", try the following example:This will produce following result:Using Image in Webpage Simple Image Insert![]()
Simple Image Insert

Set Image Width/Height
You can set image width and height based on your requirement using width and height attributes. You can specify width and height of the image in terms of either pixels or percentage of its actual size.Example
This will produce following result:Set Image Width and Height Setting image width and height![]()
Setting image width and height

Set Image Border
By default image will have a border around it, you can specify border thickness in terms of pixels using border attribute. A thickness of 0 means, no border around the picture.Example
This will produce following result:Set Image Border Setting image Border![]()
Setting image Border

Set Image Alignment
By default image will align at the left side of the page, but you can use align attribute to set it in the center or right.Example
This will produce following result:Set Image Alignment Setting image Alignment![]()
Setting image Alignment

Post a Comment
0 comments
Dear readers, after reading the Content please ask for advice and to provide constructive feedback Please Write Relevant Comment with Polite Language.Your comments inspired me to continue blogging. Your opinion much more valuable to me. Thank you.