Saturday, February 19, 2011

The Image Tag

When you are building a web page you will most likely need to have a lot of images in your page. The <IMG> tag allows you to play with images as there is more to images than just adding then to web pages. You can change there size, give them borders, provide it with a tool-tip etc.

You can add an image by saying:

<IMG SRC = "C:/myImage.gif">

The SRC is the attribute for source where we can provide it with a path of the image.

Here is the code that shows the use of Image Tag:

<IMG SRC = "C:/myHTMLWay.gif">

As you can see the the tag inserted an image into my web page.

Attributes of <IMG> Tag:

ALT: Stands for alternate text. When specified, the alternate text appears in place of the image when the image fails to load. If the image is loaded this acts as a tool-tip.

Border: The border thickness of the image, which by default is set to 0.

Height: The height of the image.

Width: The width of the image.

Align: The alignment of the text adjacent to the image.

UseMap: Specifies the image mapping to be used.

<IMG SRC = "C:/myHTMLWay.gif" ALT = "My HTML Way..." 
                          Border = "1" Height = "100" Width = "100", Align = "Center">
This is the image I created.

Notice how the size of the image is now 100 pixels, and a border appears along the image. Also the text is now aligned at the center of the image.

No comments:

Post a Comment

Please leave a comment if you have anything to say or have something to ask.. I will do my best to answer..