Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Referencing Images

  • Adding images to your page is as easy as adding links to it. In fact, the HTML code for it is very similar.

    Unlike the anchor tag, however, your document is not replaced by the referenced image. Instead, the web server retrieves the image and actually sets it "within" the HTML document in which the reference occurs and displays them both together.

  • Specifically, you will use the <IMG> tag to load images into your HTML document.

  • Like the anchor tag, you never really use the IMG tag without any attributes. Instead, you will use one of several attributes.

  • The attribute you will most often use, however, is the SRC attribute that specifies the location of an image that you would like incorporated into your HTML document.

  • Thus, the following code would retrieve the image named "ballred.gif", that is located at "www.eff.org" in the "Icons" directory and would insert it into the HTML document.
<IMG SRC    = "http://www.eff.org/Icons/ballred.gif"
     HEIGHT = n
     WIDTH  = n
     ALT    = alternate text
     BORDER = 0
     >

  • One final note about referencing images. It is very possible that someone will be viewing your page in a non-graphical way. Perhaps they are blind. Perhaps they have turned off image loading to speed up their browsing (since images take a long time to load up). Or perhaps they are using a non-graphical web browser like LYNX.

  • Whatever the case, it is considered good form to always include a value for the ALT attribute in the IMG tag. The ALT attribute specifies some text that will be displayed if the image cannot be and looks like the following:

<IMG SRC    = "http://www.eff.org/Icons/ballred.gif"
     ALT    = "alternate text"
     HEIGHT = n
     WIDTH  = n
     BORDER = 0
     >	

  • The IMG tag has several other attributes that we will discuss in the next few pages, but that we will include in the following table here:

Attribute Description Example
ALIGN [1] Aligns text around an image in a word wrap style. Can be TOP, MIDDLE, BOTTOM, RIGHT or LEFT. <IMG SRC = "x.gif" ALIGN = "LEFT">
ALT Specifies text that should be displayed if the user cannot see images. <IMG SRC = "x.gif" ALT = "x">
BORDER [2] Specifies the pixel size of the border that surrounds the image <IMG SRC = "x.gif" BORDER = "10">
HEIGHT Specifies the height of the image in pixels <IMG SRC = "x.gif" HEIGHT = "202">
HSPACE [3] Specifies the horizontal margin around the image in pixels <IMG SRC = "x.gif" HSPACE = "5">
SRC Specifies the source of the image that should be displayed <IMG SRC = "x.gif">
VSPACE [4] Specifies the vertical margin around the image in pixels <IMG SRC = "x.gif" VSPACE = "5">
WIDTH Specifies the width of the image in pixels <IMG SRC = "x.gif" WIDTH = "202">

Images
Introduction to Web Design | Table of Contents
Exercise Six


Up to => Home / Authoring / HTML / Tutorial




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers