HTML and CSS Reference
In-Depth Information
there aren't any gradated areas. If using transparency in the image, usually PNG-24
will provide a better result, because it will handle the transition between opaque and
transparent areas of the image better.
Note Google recently introduced a new image format for the Web called WebP (pro-
nounced “weppy”) that is a competitor to the JPEG format. It's worth keeping your eye
on, but currently browser support is too minimal (Google Chrome and Opera) to think
about using it as your primary image format. You can find more information at ht-
tp:// .
The next attribute, alt , is for providing alternative content for the image if the image
is not available or viewable. The text in the alt attribute should reasonably represent
the image and not change the meaning of the content on the page if the image were re-
moved. The alt attribute can be an empty string of text ( "" ) if it is supplemental or
redundant with other information on the page or if it is purely decorative, in which case
CSS would likely be a better way to handle the image (see the “Is img obsolete? What
about CSS?” sidebar). The alt attribute may also be omitted in cases where a textual
representation of the image is not possible to provide, such as in a dynamically added
image uploaded by a user, where the actual meaning of the image may not immediately
be known. How to properly use the alt attribute in different contexts is a matter of sur-
prising amounts of debate, but fundamentally it should be thought of as a replacement
of the image, not a description of the image. A description is more correctly served by
the title attribute. For instance, for an image showing a map of Andorra, it would be
incorrect to provide alternative text that says “Map of Andorra” if the intent was to show
Andorra's location in the world. A better alternative text would replicate the meaning
conveyed by the image. In this case, it may be something like: “Andorra is a landlocked
western European country bordered by Spain to the southwest and France to the north-
east” ( Figure 5-1 ) .
2 Where supported (for instance, in Safari), PDF documents will display only the first page, be-
cause img is not allowed to show paged content.
Search WWH ::

Custom Search