How to add images to a webpage

A webpage without images will not look good. Pages with more images can attract large number readers than pages without images.
The element img will be used to insert an image in to a webpage. This img element should be defined differently for HTML and XHTML.
Actually, empty elements like <img> may not necessarily to close with an end tag in HTML. Wherein XTHML markup, every elements must be closed with an end tag.

Sample image tag for HTML:

<img src="images/screenshot.jpg" width="300" height="225" alt="alt text">

Sample image tag for XHTML:

<img src="images/screenshot.jpg" width="300" height="225" alt="alt text" />

Suppose, if you want to assign a link to the image, the code should look like
For HTML

<a href="#"><img src="images/screenshot.jpg" alt="alt text" width="300" height="225" border="0"></a>

For XHTML

<a href="#"><img src="images/screenshot.jpg" alt=" alt text " width="300" height="225" border="0" /></a>

Latest tutorials in Webdesign



3 Comments

caspien says: 24 November 2008

Hey its working man.thanks

sam says: 29 November 2008

H,
Really cool and must tutorial. If you add some coding before and after the image tag (coding) (i.e ) where the coding should be, then it will really helps the Starter like me. Its just a suggestion.

HemAnanth says: 3 December 2008

its good man