With HTML you can display images in a document |
||
|---|---|---|
The Image Tag and the Src AttributeIn HTML, images are defined with the <img> tag.The <img> tag is empty, which means that it contains attributes only and it has no closing tag. To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display on your page. The syntax of defining an image: <img src="url"> The Alt AttributeThe alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text:
The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The browser will then display the alternate text instead of the image. It is a good practice to include the "alt" attribute for each image on a page, to improve the display and usefulness of your document for people who have text-only browsers. If an HTML file contains ten images - eleven files are required to display the page right. Loading images take time, so my best advice is: Use images carefully. |
||
Insert images <p> <p> |
An image:
A moving image:
Note that the syntax of inserting a moving image is no different from that of a non-moving image. |
|
Insert images from different locations <p> <p> |
An image from another folder:
An image from KCC:
|
|
Aligning images <p> <p> <p> <p>Note that bottom alignment is the default alignment</p> <p> <p> <p> |
An image
An image
An image
Note that bottom alignment is the default alignment
An image
An image after the text
|
|
Let the image float <p> <p> |
|
|
Adjust images to different sizes <p> <p> <p> <p>
|
You can make a picture larger or smaller changing the values in the "height" and "width" attributes of the img tag. |
|
Make a hyperlink of an image <p> |
||
Good background image <body background="paper.gif"> <h3>Image Background</h3> <p>Both gif and jpg files can be used as HTML backgrounds.</p> <p>If the image is smaller than the page, the image will repeat itself.</p> |
Image BackgroundBoth gif and jpg files can be used as HTML backgrounds. If the image is smaller than the page, the image will repeat itself. |
|
Bad background image <body background="rock.jpg"> <h3>Image Background</h3> <p>Both gif and jpg files can be used as HTML backgrounds.</p> <p>If the image is smaller than the page, the image will repeat itself.</p>
|
Image BackgroundBoth gif and jpg files can be used as HTML backgrounds. If the image is smaller than the page, the image will repeat itself |
|
| Create an image map This example demonstrates how to create an image map, with clickable regions. Each of the regions is a hyperlink. <p> <img src="planets.gif" <map id="planetmap" name="planetmap"> <area shape="rect" <area shape="circle" <area shape="circle" </map> <p><b>Note:</b> The "usemap" attribute in the img element refers to the "id" or "name" (browser dependant) attribute in |
Click on one of the planets to watch it closer:
Note: The "usemap" attribute in the img element refers to the "id" or "name" (browser dependant) attribute in the map element, therefore we have added both the "id" and "name" attributes to the map element. |
|
| http://www.w3schools.com/ | ||