You can use other attributes of the <img /> tag to change the image size. Table 8.1 shows some of these attributes, and the following sections provide some examples for adding these attributes to your documents.
Adjusting the Height and WidthYou can adjust the size of your image using the height and width attributes. You can set these attributes to a fixed pixel size or a percentage of the page size. Look at the following sample HTML lines. The first line sets the happy face image from Figure 8.1 to a fixed pixel size of 60 pixels high and 60 pixels wide. The second line sets the same image to 6% of the page width and 10% of the page height. Figure 8.3 shows how both of these look in the browser. <img src="/books/1/174/1/html/2/http://www.thingstobehappyabout.com/face2.gif" alt="This looks just like me!" height="60" width="60" /> <img src="/books/1/174/1/html/2/http://www.thingstobehappyabout.com/face2.gif" alt="This looks just like me!" height="10%" width="6%" /> Figure 8.3. The height and width attributes control the size of the image.The Web browser interprets pixels and percentages equally well when rendering an image. You need to remember, however, that your Web visitors may not use the same monitor display settings that you do. What does this mean to you? My monitor is set to 800 pixels wide. In the preceding HTML sample, I set the happy face image to 6% of the page width, or 48 pixels wide. If I viewed the same page on a monitor set to 1024 pixels wide, that same 6% of the page width would now equal 61 pixels, which is much wider than I wanted. If you truly want the image to be a certain percentage of the page (as you might for a graphical line), then use percentages. Using percentages ensures that the image will take up the space you want it to. If you want the image to appear a specific size, use the pixel setting. Caution
Tip
Aligning Text and ImagesYou can use the align attribute of the <img /> tag to force an image to appear on the left or right of a section of text. You can see an example of this attribute in action in Figure 8.4. <img src="/books/1/174/1/html/2/http://www.thingstobehappyabout.com/face2.gif" alt="This looks just like me!" height="60" width="60" align="right" /> Figure 8.4. Notice how the align attribute forces the image to align with the text.You also can use the align attribute to vertically align an image with the text. The align attribute has three more values: top, bottom, and center, which are discussed in the following list. Figure 8.4 shows you a sample HTML document using the vertical alignment properties.
Caution
|