HTML tag for images is img. This tag has no closing one. The attribute src specifies the URL of the image file and the attribute alt specifies the text to be shown by the text-only browsers. The attribute alt is required.
The img tag also supports other attributes to be considered later.
Layout | HTML tags |
---|---|
<img src="sunset.gif" alt="sunset" /> |
The syntax for the image align attribute is:
Examples:
align="bottom" | align="middle" |
---|---|
sample text sample text sample text sample text sample text sample text sample text sample text sample text | sample text sample text sample text sample text sample text sample text sample text sample text sample text |
align="middle" | align="top" |
sample text sample text sample text sample text sample text sample text sample text sample text sample text | sample text sample text sample text sample text sample text sample text sample text sample text sample text |
align="left" | align="right" |
sample text sample text sample text sample text sample text sample text sample text sample text sample text | sample text sample text sample text sample text sample text sample text sample text sample text sample text |
The vertical and horizontal space around the image can be increased with the vspace and hspace attributes:
Examples:
|
|
Width and height attributes instruct the browser to display the image at a specific size. These attributes can be used to increase or decrease the image size. The syntax for setting these attributes is:
The original image size is (width)x(height) = 132x116. If one of the attributes width/height is not specified the image will be scaled proportionally.
|
|
|
Background images can be specified within the <body> tag. The syntax for inserting a background image is:
Usually the background image is a small file which be multiplied automatically by the browser. Examples of background images are presented below. Clicking on the buttons opens a small new window with the corresponding background image.
or | or |