Syntax for defining an image:
<img src=”url” alt=”some text” />
The img tag is used to put an image in an HTML document and it looks like this:
<img src="http://webcodemaster.blogspot.in/logo.gif" width="120" height="90" alt="webcodemaster">
HTML Images - The Alt Attribute
The required alt attribute specifies an alternate text for an image, if the image cannot be displayed.The value of the alt attribute is an author-defined text:
<img src="developersplatform.gif" alt="logo">
The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).
HTML Images - Set Height and Width of an Image
The height and width attributes are used to specify the height and width of an image.The attribute values are specified in pixels by default:
<img src="developersplatform.gif" alt="logo" width="42" height="42">
Tip: It is a good practice to specify both the height and width attributes for an image. If these attributes are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load).

0 comments:
Post a Comment