In order to insert the image into the web document there are some attributes to use. By using those attributes user can adjust the image in many ways and some attributes are listed below.
- Src Attribute
- alt Attribute
- Height and Width Attribute
- Align Attribute
Src Attribute
The
src attribute advises the program destination of the image in which value is a
URL and, the URL defined as
absolute URL or
relative URL. The syntax below demonstrates Src Attribute.
[html]
< img src=”splessons.jpg” / >
[/html]
Images for users web site images are always beside of user server.which is not a right practice to import the images from different sites because the site owner chooses to move that picture then user no longer to see the image. If the user have the images on his server,which is known as
absolute URL, The value should be similar to
relative URL.
Most of the users are created separate folders for the images and for the large web sites they might create different folders for the different type of images.
alt Attribute
The alt attribute always available with the each
<img> element and value is image description. The snippet below demonstrates the syntax of the alt attribute.
[html]
< img src=”logo.gif” alt=”Wrox logo” / >
[/html]
alt text describe the value of the attribute describe the image because of these are shown below.
- If the browser can not display the image then instead of image text will displays.
- For the visual implements web browsers are used a software named as Screen Reader to read the page in that alt text describe the image they cannot see.
Height and Width Attribute
The height and width attributes is used to get height and width of the image, and the values should be used for these attributes are quite often in
pixels. The syntax below demonstrates the Height and Width attribute.
[html]
<img src="splessons.jpg" alt="splessons.com" width="104" height="142">
[/html]
Actually, the values of these attributes can be written in a percentage of the browser screen. On the other hand if the image is present inside a element which should takes just a part of the page, which known as a
containing element , then it should be a percentage of the contained element. The code below demonstrates the adjusting the height and width attributes of the image as shown below.
[html]
<!DOCTYPE html>
<html>
<body>
<img src="splessons.jpg" alt="splessons.com" width="104" height="142">
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Align Attribute
The align attribute is used to arrange an image inside a page i.e either left or right or centre. The syntax of the align attribute as shown below.
[html]
<img src="splessons.jpg" alt=”splessons.com” align=”left” width="104" height="142">
[/html]
Values of the Align attribute as shown in below table.
Value |
Purposee |
Top |
Which is used arranged the image at the top of the page. |
middle |
Which is used arranged the image at the middle of the page. |
bottom |
Which is used arranged the image at the middle of the page. |
left |
Which is used arranged the image at the left of the page. |
Right |
Which is used arranged the image at the right of the page. |
The code below demonstrates the align positions of the image ads shown below.
[html]
<!DOCTYPE html>
<html>
<body>
<img src="splessons.jpg" alt=”splessons.com” align=”left” width="104" height="142">
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.