|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Your basic <IMG> tag, then, should look like the following: <IMG SRC=URL_of_image_file WIDTH=width_in_pixels HEIGHT=height_in_pixels ALT=alternative_text_description> Most sites make conscientious use of these attributes in each <IMG> tag. Figure 5.1, for example, shows the banner graphic on the World Wide Web Consortiums main page along with the corresponding HTML source code in Listing 5.1.
Listing 5.1 <IMG> Tag from the W3C Home Page <TD COLSPAN=4"> <H1><IMG ALT=W3C HEIGHT=48 WIDTH=307 SRC=Icons/WWW/w3c_main></H1> <H2><I>Leading the Web to its Full Potential...</I></H2> ... </TD>
Adding a BorderThe BORDER attribute gives you a simple way to instruct the browser to place a border around an image. BORDER is set equal to the number of pixels wide you want the border to be. Figure 5.2 shows an image with a seven-pixel-wide border. The default border is no border.
Adding Space Around Your ImageWhitespace around an image is called gutter space or runaround. Putting a little extra space around an image is a good way to give it some breathing room on the page and make it stand out better. Runaround is controlled by the HSPACE and VSPACE attributes. Each is set to the number of pixels of extra space to leave to the right and left of an image (HSPACE) or above and below an image (VSPACE). Figures 5.3 and 5.4 show some images with varying amounts of HSPACE and VSPACE. In each figure, all images have either extra HSPACE (see Figure 5.3) or extra VSPACE (see Figure 5.4) around them.
The ALIGN Attribute and Floating ImagesThe ALIGN attribute of the <IMG> tag can take on one of the five values summarized in Table 5.2. TOP, MIDDLE, and BOTTOM refer to how text should be aligned following the image. LEFT and RIGHT create floating images in either the left or right margin.
Figure 5.5 shows text aligned with TOP, MIDDLE, and BOTTOM (the default alignment). One important thing to note with TOP and MIDDLE alignments is that once the text reaches a point where it needs to break, it breaks at a point below the image and leaves some whitespace between the lines of text.
Values of LEFT and RIGHT for the ALIGN attribute were adopted as part of the HTML 3.2 standard to allow for floating images that permit text to wrap around them. Figure 5.6 shows an image floating in the left margin with text wrapping around it to the right.
Floating images opened the door to many creative and interesting layouts. It is even possible to overlap images by floating one in the left margin and one in the right margin. The advent of floating images created a need for a way to break to the first left or right margin that is clear of a floating image. To satisfy this need, the CLEAR attribute was added to the <BR> tag. Setting CLEAR to LEFT breaks to the first instance of a left margin that is clear of floating images. CLEAR=RIGHT does the same thing, except it breaks to the first right margin. You can clear both margins by setting CLEAR=ALL.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |