HOME

HTML Basic
HTML HOME
HTML & WWW
HTML Introduction
HTML Elements
HTML Basic Tags
HTML Formatting
HTML Entities
HTML Links
HTML Frames
HTML Tables
HTML Lists
HTML Forms
HTML Images
HTML Background

HTML Advanced
HTML Layout
HTML Fonts
HTML 4.0 Why
HTML Styles
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML Webserver

Examples/Quiz
HTML Examples
HTML Quiz Test

References
HTML Quick List
HTML Tag List
HTML Attributes
HTML Events
HTML ASCII
HTML Entities
HTML Colors
HTML Colorvalues
HTML Colornames
HTML HTTP

Please visit our sponsors !

HTML Images

Previous Next

With HTML you can display images in a document.


Examples

Insert images
This example demonstrates how to display images in your Web page.

Insert images from different locations
This example demonstrates how to display images from another folder or another server in your Web page.

More Examples


The Image Tag and the Src Attribute

In 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 URL points to the location where the image is stored. An image named "boat.gif" located in the directory "images" on "www.w3schools.com" has the URL: http://www.w3schools.com/images/boat.gif.

The browser puts the image where the image tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph.


The Alt Attribute

The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text:

<img src="boat.gif" alt="Big Boat">

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.


Basic Notes - Useful Tips

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.


More Examples

Background image
This example demonstrates how to add a background image to an HTML page.

Aligning images
This example demonstrates how to align an image within the text.

Let the image float
This example demonstrates how to let an image float to the left or right of a paragraph.

Adjust images to different sizes
This example demonstrates how to adjust images to different sizes.

Display an alternate text for an image
This example demonstrates how to display an alternate text for an image. The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. It is a good practice to include the "alt" attribute for each image on a page.

Make a hyperlink of an image
This example demonstrates how to use an image as a link.

Create an image map
This example demonstrates how to create an image map, with clickable regions. Each of the regions is a hyperlink.

Turn an image into an image map
This example demonstrates how to turn an image into an image map. You will see that if you move the mouse over the image, the coordinates will be displayed on the status bar.


Image Tags:

NN: Netscape, IE: Internet Explorer, W3C: Web Standard

Start Tag NN IE W3C Purpose
<img> 3.0 3.0 3.2 Defines an image
<map> 3.0 3.0 3.2 Defines an image map
<area> 3.0 3.0 3.2 Defines an area inside an image map


Previous Next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

ASPHits
Active Server Pages Resource Web Site


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search