Saturday 28 September 2013

HTML Image Tags and Alt Attribute of img tag

Images may be added to your web page as easily as links. The <img> tag is used to define an image. This tag does not have a closing tag. However, there are parameters defined for this tag. The following example adds an image to a Web Page:
<img src="sunset.gif" alt=”This will be shown if the image does not display.” />
The alt parameter is used to define a piece of text to be displayed for when the browser doesn't successfully load the image. This can happen if there is a problem with the internet traffic, or if one of the connections between the server and the client (browser) gets broken, or if the web surfer clicked on the stop button to stop loading the image.
To define the height and width of the image, rather than letting the browser compute the size, use the height and width attributes.
HTML Code:
<img src="sunset.gif" height="50" width="100" alt=”This will be shown if the image does not display.”  />
Use the align and valign attributes to place images within your body, tables, or sections.
align (Horizontal)
                                right
                                left
                                center
valign (Vertical)
                                top
                                bottom
                                center
                                 
                                          Below is an example of how to align an image to the right of a paragraph. Here we are going to align the image to the right side of the page.
                                           
HTML Code:
<p>This is paragraph 1, yes it is...</p>
<p>
<img src="sunset.gif" align="right" alt=”This will be shown if the image does not display.”  />
The image will appear along the...isn't it?
</p>
<p>This is the third paragraph that appears...</p>
Images can be used as a link on a web page. As you can see on many web pages the small images called thumbnails are used for image links. In this process image or the thumbnail is placed in an anchor tag. For example
<a href="http://www.espn.com" target="_blank"> <img src="myPic.gif"> </a>



No comments:

Post a Comment