12.2. Image Basics
Before jumping into the finer points of the <img> tag, let's back up and consider general graphics usage issues.
12.2.1. Inline Graphic Uses
Graphic files can be used in a number of ways on the Web. Images may be used as background tiles (added with the background attribute in the <body> tag as noted in Chapter 9, "Structural HTML Tags"). You can also create a link to a graphic file that displays either in the browser window or in a helper application if it is in a format that cannot be displayed by the browser.
This chapter focuses on inline images, graphics that are displayed in the browser window as part of the flow of the contents of the document. Inline images are placed on the page with the <img> tag. The overwhelming majority of graphics on the Web are used as inline images, including banners, buttons, logos, and so on. Graphics can serve a variety of functions:
12.2.2. Acceptable Graphics Formats
A graphic needs to be in either GIF or JPEG format to be displayed as an inline image by the vast majority of browsers. Furthermore, the files need to be named with the proper suffixes -- .gif for GIF files, .jpeg or .jpg for JPEG -- in order to be recognized by the browser.
There is a third format, PNG (pronounced "ping"), which was designed specifically with web distribution in mind; however, only Version 4 and higher browsers support PNG files (suffix .png) as inline graphics, and they don't support all of PNG's most attractive features. Until PNG gains better support, stick with either GIF or JPEG.
These graphics file formats, as well as other requirements for putting graphics online, are discussed in detail in the chapters of Part III, "Graphics".
Copyright © 2002 O'Reilly & Associates. All rights reserved.