Chinaunix首页 | 论坛 | 博客
  • 博客访问: 163850
  • 博文数量: 45
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 454
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-19 13:35
文章分类

全部博文(45)

文章存档

2011年(1)

2009年(44)

我的朋友

分类: 系统运维

2009-10-27 09:37:23

Objects, Images, and Applets

Introduction to objects, images, and applets

HTML's multimedia features allow authors to include images, applets (programs that are automatically downloaded and run on the user's machine), video clips, and other HTML documents in their pages.

For example, to include a PNG image in a document, authors may write:


Here's a closeup of the Grand Canyon: This is a closeup of the Grand Canyon.

Previous versions of HTML allowed authors to include images (via ) and applets (via ). These elements have several limitations:

  • They fail to solve the more general problem of how to include new and future media types.
  • The element only works with Java-based applets. This element is in favor of .
  • They pose accessibility problems.

To address these issues, HTML 4 introduces the element, which offers an all-purpose solution to generic object inclusion. The element allows HTML authors to specify everything required by an object for its presentation by a user agent: source code, initial values, and run-time data. In this specification, the term "object" is used to describe the things that people want to place in HTML documents; other commonly used terms for these things are: applets, plug-ins, media handlers, etc.

The new element thus subsumes some of the tasks carried out by existing elements. Consider the following chart of functionalities:

Type of inclusion Specific element Generic element
Image
Applet (.)
Another HTML document

The chart indicates that each type of inclusion has a specific and a general solution. The generic element will serve as the solution for implementing future media types.

To include images, authors may use the element or the element.

, authors should use the element as the element is .

To include one HTML document in another, authors may use either the new element or the element. In both cases, the embedded document remains independent of the main document. Visual user agents may present the embedded document in a distinct window within the main document. Please consult the notes on embedded documents for a comparison of and for document inclusion.

Images and other included objects may have hyperlinks associated with them, both through the standard , but also via image maps. An image map specifies active geometric regions of an included object and assigns a link to each region. When activated, these links may cause a document to be retrieved, may run a program on the server, etc.

In the following sections, we discuss the various mechanisms available to authors for multimedia inclusions and creating image maps for those inclusions.

Including an image: the element




Start tag: required, End tag: forbidden

Attribute definitions

=
This attribute specifies the location of the image resource. Examples of widely recognized image formats include GIF, JPEG, and PNG.
=
This attribute specifies a link to a long description of the image. This description should supplement the short description provided using the attribute. When the image has an associated image map, this attribute should provide information about the image map's contents. This is particularly important for server-side image maps. Since an element may be within the content of an element, the user agent's mechanism in the user interface for accessing the "longdesc" resource of the former must be different than the mechanism for accessing the resource of the latter.
=
This attribute names the element so that it may be referred to from style sheets or scripts. Note. This attribute has been included for backwards compatibility. Applications should use the attribute to identify elements.

Attributes defined elsewhere

The element embeds an image in the current document at the location of the element's definition. The element has no content; it is usually replaced inline by the image designated by the attribute, the exception being for left or right-aligned images that are out of line.

In an earlier example, we defined a link to a family photo. Here, we insert the photo directly into the current document:


I just returned from vacation! Here's a photo of my family at the lake: A photo of my family at the lake.

This inclusion may also be achieved with the element as follows:


I just returned from vacation! Here's a photo of my family at the lake: A photo of my family at the lake.

The attribute specifies alternate text that is rendered when the image cannot be displayed (see below for information on ). User agents must render alternate text when they cannot support images, they cannot support a certain image type or when they are configured not to display images.

The following example shows how the longdesc attribute can be used to link to a richer description:


HP Labs Site Map

The attribute provides a short description of the image. This should be sufficient to allow users to decide whether they want to follow the link given by the longdesc attribute to the longer description, here "sitemap.html".

Please consult the section on the visual presentation of objects, images, and applets for information about image size, alignment, and borders.

the element



Start tag: required, End tag: required

Attribute definitions

=
This attribute may be used to specify the location of an object's implementation via a URI. It may be used together with, or as an alternative to the attribute, depending on the type of object involved.
=
This attribute specifies the base path used to resolve relative URIs specified by the , , and attributes. When absent, its default value is the base URI of the current document.
=
This attribute specifies the content type of data expected when downloading the object specified by . This attribute is optional but recommended when is specified since it allows the user agent to avoid loading information for unsupported content types. When absent, it defaults to the value of the type attribute.
=
This attribute may be used to specify the location of the object's data, for instance image data for objects defining images, or more generally, a serialized form of an object which can be used to recreate it. If given as a relative URI, it should be interpreted relative to the codebase attribute.
=
This attribute specifies the content type for the data specified by . This attribute is optional but recommended when is specified since it allows the user agent to avoid loading information for unsupported content types. If the value of this attribute differs from the HTTP Content-Type returned by the server when the object is retrieved, the HTTP Content-Type takes precedence.
=
This attribute may be used to specify a space-separated list of URIs for archives containing resources relevant to the object, which may include the resources specified by the and attributes. Preloading archives will generally result in reduced load times for objects. Archives specified as relative URIs should be interpreted relative to the codebase attribute.
When present, this boolean attribute makes the current definition a declaration only. The object must be instantiated by a subsequent definition referring to this declaration.
=
This attribute specifies a message that a user agent may render while loading the object's implementation and data.

Attributes defined elsewhere

for rendering common data types such as text, GIF images, colors, fonts, and a handful of graphic elements. To render data types they don't support natively, user agents generally run external applications. The element allows authors to control whether data should be rendered externally or by some program, specified by the author, that renders the data within the user agent.

In the most general case, an author may need to specify three types of information:

  • The implementation of the included object. For instance, if the included object is a clock applet, the author must indicate the location of the applet's executable code.
  • The data to be rendered. For instance, if the included object is a program that renders font data, the author must indicate the location of that data.
  • Additional values required by the object at run-time. For example, some applets may require initial values for parameters.

The element allows authors to specify all three types of data, but authors may not have to specify all three at once. For example, some objects may not require data (e.g., a self-contained applet that performs a small animation). Others may not require run-time initialization. Still others may not require additional implementation information, i.e., the user agent itself may already know how to render that type of data (e.g., GIF images).

and the location of the data to be rendered via the element. To specify run-time values, however, authors use the element, which is discussed in the section on

The element may also appear in the content of the element. Since user agents generally do not render elements in the , authors should ensure that any elements in the do not specify content that may be rendered. Please consult the section on for an example of including the element in the element.

Please consult the section on for information about elements in forms.

This document does not specify the behavior of elements that use both the attribute to identify an implementation and the attribute to specify data for that implementation. In order to ensure portability, authors should use the element to tell implementations where to retrieve additional data.

A user agent must interpret an element according to the following precedence rules:

  1. The user agent must first try to render the object. It should not render the element's contents, but it must examine them in case the element contains any direct children that are elements (see ) or elements (see client-side image maps).
  2. If the user agent is not able to render the object for whatever reason (configured not to, lack of resources, wrong architecture, etc.), it must try to render its contents.

content in elements that appear in the element.

In the following example, we insert an analog clock applet in a document via the element. The applet, written in the Python language, requires no additional data or run-time values. The attribute specifies the location of the applet:

    

Note that the clock will be rendered as soon as the user agent interprets this declaration. It is possible to delay rendering of an object by first declaring the object (described below).

Authors should complete this declaration by including alternate text as the contents of in case the user agent cannot render the clock.

    

An animated clock.

of the element's design is that it offers a mechanism for specifying alternate object renderings; each embedded declaration may specify alternate content types. If a user agent cannot render the outermost , it tries to render the contents, which may be another element, etc.

In the following example, we embed several declarations to illustrate how alternate renderings work. A user agent will attempt to render the first element it can, in the following order: (1) an Earth applet written in the Python language, (2) an MPEG animation of the Earth, (3) a GIF image of the Earth, (4) alternate text.

The Earth as seen from space.

The outermost declaration specifies an applet that requires no data or initial values. The second declaration specifies an MPEG animation and, since it does not define the location of an implementation to handle MPEG, relies on the user agent to handle the animation. We also set the type attribute so that a user agent that knows it cannot render MPEG will not bother to retrieve "TheEarth.mpeg" from the network. The third declaration specifies the location of a GIF file and furnishes alternate text in case all other mechanisms fail.

Inline vs. external data. Data to be rendered may be supplied in two ways: inline and from an external resource. While the former method will generally lead to faster rendering, it is not convenient when rendering large quantities of data.

Here's an example that illustrates how inline data may be fed to an :

A clock.

Please consult the section on the visual presentation of objects, images, and applets for information about object size, alignment, and borders.

the element



Start tag: required, End tag: forbidden

Attribute definitions

=
This attribute defines the name of a run-time parameter, assumed to be known by the inserted object. Whether the property name is case-sensitive depends on the specific object implementation.
=
This attribute specifies the value of a run-time parameter specified by . Property values have no meaning to HTML; their meaning is determined by the object in question.
= data|ref|object
This attribute specifies the type of the value attribute. Possible values:
  • data: This is default value for the attribute. It means that the value specified by value will be evaluated and passed to the object's implementation as a string.
  • ref: The value specified by value is a URI that designates a resource where run-time values are stored. This allows support tools to identify URIs given as parameters. The URI must be passed to the object as is, i.e., unresolved.
  • object: The value specified by value is an identifier that refers to an declaration in the same document. The identifier must be the value of the attribute set for the declared element.
=
This attribute specifies the content type of the resource designated by the value attribute only in the case where is set to "ref". This attribute thus specifies for the user agent, the type of values that will be found at the URI designated by value.

Attributes defined elsewhere

elements specify a set of values that may be required by an object at run-time. Any number of elements may appear in the content of an or element, in any order, but must be placed at the start of the content of the enclosing or element.

The syntax of names and values is assumed to be understood by the object's implementation. This document does not specify how user agents should retrieve name/value pairs nor how they should interpret parameter names that appear twice.

We return to the clock example to illustrate the use of : suppose that the applet is able to handle two run-time parameters that define its initial height and width. We can set the initial dimensions to 40x40 pixels with two elements.

    

This user agent cannot render Python applications.

In the following example, run-time data for the object's "Init_values" parameter is specified as an external resource (a GIF file). The value of the attribute is thus set to "ref" and the value is a URI designating the resource.

valuetype="ref">

Note that we have also set the attribute so that the user agent may display a message while the rendering mechanism loads.

When an element is rendered, user agents must search the content for only those elements that are direct children and "feed" them to the .

Thus, in the following example, if "obj1" is rendered, "param1" applies to "obj1" (and not "obj2"). If "obj1" is not rendered and "obj2" is, "param1" is ignored, and "param2" applies to "obj2". If neither is rendered, neither applies.

The location of an object's implementation is given by a URI. As we discussed in the , the first segment of an absolute URI specifies the naming scheme used to transfer the data designated by the URI. For HTML documents, this scheme is frequently "http". Some applets might employ other naming schemes. For instance, when specifying a Java applet, authors may use URIs that begin with "java" and for ActiveX applets, authors may use "clsid".

In the following example, we insert a Java applet into an HTML document.

By setting the attribute, a user agent can decide whether to retrieve the Java application based on its ability to do so.



Some rendering schemes require additional information to identify their implementation and must be told where to find that information. Authors may give path information to the object's implementation via the attribute.


        codebase=""

The following example specifies (with the attribute) an ActiveX object via a URI that begins with the naming scheme "clsid". The attribute locates the data to render (another clock).

This application is not supported.

The preceding examples have only illustrated isolated object definitions. When a document is to contain more than one instance of the same object, it is possible to separate the declaration of the object from its instantiations. Doing so has several advantages:
  • Data may be retrieved from the network by the user agent one time (during the declaration) and reused for each instantiation.
  • It is possible to instantiate an object from a location other than the object's declaration, for example, from a link.
  • It is possible to specify objects as run-time data for other objects.

To declare an object so that it is not executed when read by the user agent, set the boolean attribute in the element. At the same time, authors must identify the declaration by setting the attribute in the element to a unique value. Later instantiations of the object will refer to this identifier.

A declared must appear in a document before the first instance of that .

An object defined with the attribute is instantiated every time an element that refers to that object requires it to be rendered (e.g., a link that refers to it is activated, an object that refers to it is activated, etc.).

In the following example, we declare an and cause it to be instantiated by referring to it from a link. Thus, the object can be activated by clicking on some highlighted text, for example.

The Earth as seen from space. ...later in the document...

A neat animation of The Earth!

The following example illustrates how to specify run-time values that are other objects. In this example, we send text (a poem, in fact) to a hypothetical mechanism for viewing poems. The object recognizes a run-time parameter named "font" (say, for rendering the poem text in a certain font). The value for this parameter is itself an object that inserts (but does not render) the font object. The relationship between the font object and the poem viewer object is achieved by (1) assigning the "tribune" to the font object declaration and (2) referring to it from the element of the poem viewer object (with and value).

...view the poem in KublaKhan.txt here...

You're missing a really cool poem viewer ...

User agents that don't support the attribute must render the contents of the declaration.

: the element

APPLET is in favor of .

See the for the formal definition.

Attribute definitions

=
This attribute specifies the base URI for the applet. If this attribute is not specified, then it defaults the same base URI as for the current document. Values for this attribute may only refer to subdirectories of the directory containing the current document. Note. While the restriction on subdirectories is a departure from common practice and the HTML 3.2 specification, the HTML Working Group has chosen to leave the restriction in this version of the specification for security reasons.
=
This attribute specifies either the name of the class file that contains the applet's compiled applet subclass or the path to get the class, including the class file itself. It is interpreted with respect to the applet's codebase. One of or must be present.
=
This attribute specifies a name for the applet instance, which makes it possible for applets on the same page to find (and communicate with) each other.
=
This attribute specifies a comma-separated list of URIs for archives containing classes and other resources that will be "preloaded". The classes are loaded using an instance of an AppletClassLoader with the given . Relative URIs for archives are interpreted with respect to the applet's codebase. Preloading resources can significantly improve the performance of applets.
=
This attribute names a resource containing a serialized representation of an applet's state. It is interpreted relative to the applet's codebase. The serialized data contains the applet's class name but not the implementation. The class name is used to retrieve the implementation from a class file or archive.

When the applet is "deserialized" the start() method is invoked but not the init() method. Attributes valid when the original object was serialized are not restored. Any attributes passed to this instance will be available to the applet. Authors should use this feature with extreme caution. An applet should be stopped before it is serialized.

Either or must be present. If both and are given, it is an error if they provide different class names.

=
This attribute specifies the initial width of the applet's display area (excluding any windows or dialogs that the applet creates).
=
This attribute specifies the initial height of the applet's display area (excluding any windows or dialogs that the applet creates).

Attributes defined elsewhere

This element, supported by all Java-enabled browsers, allows designers to embed a Java applet in an HTML document. It has been in favor of the element.

The content of the acts as alternate information for user agents that don't support this element or are currently configured not to support applets. User agents must ignore the content otherwise.

DEPRECATED EXAMPLE:
In the following example, the element includes a Java applet in the document. Since no is supplied, the applet is assumed to be in the same directory as the current document.


Java applet that draws animated bubbles.

This example may be rewritten with as follows:

Java applet that draws animated bubbles.

Initial values may be supplied to the applet via the element.

DEPRECATED EXAMPLE:
The following sample Java applet:



Java applet that plays a welcoming sound.

may be rewritten as follows with :



Java applet that plays a welcoming sound.

Notes on embedded documents

Sometimes, rather than to a document, an author may want to embed it directly into a primary HTML document. Authors may use either the element or the element for this purpose, but the elements differ in some ways. Not only do the two elements have different content models, the element may be a target frame (see the section on for details) and may be "selected" by a user agent as the focus for printing, viewing HTML source, etc. User agents may render selected frames elements in ways that distinguish them from unselected frames (e.g., by drawing a border around the selected frame).

An embedded document is entirely independent of the document in which it is embedded. For instance, relative URIs within the embedded document according to the base URI of the embedded document, not that of the main document. An embedded document is only rendered within another document (e.g., in a subwindow); it remains otherwise independent.

For instance, the following line embeds the contents of embed_me.html at the location where the definition occurs.

...text before...

Warning: embed_me.html could not be embedded.

...text after...

Recall that the contents of must only be rendered if the file specified by the attribute cannot be loaded.

The behavior of a user agent in cases where a file includes itself is not defined.

Image maps allow authors to specify regions of an image or object and assign a specific action to each region (e.g., retrieve a document, run a program, etc.) When the region is activated by the user, the action is executed.

An image map is created by associating an object with a specification of sensitive geometric areas on the object.

There are two types of image maps:

  • Client-side. When a user activates a region of a client-side image map with a mouse, the pixel coordinates are interpreted by the user agent. The user agent selects a link that was specified for the activated region and follows it.
  • Server-side. When a user activates a region of a server-side image map with a mouse, the pixel coordinates of the click are sent to the server-side agent specified by the attribute of the element. The server-side agent interprets the coordinates and performs some action.

Client-side image maps are preferred over server-side image maps for at least two reasons: they are accessible to people browsing with non-graphical user agents and they offer immediate feedback as to whether or not the pointer is over an active region.

Client-side image maps: the and elements



Start tag: required, End tag: required


onfocus            #IMPLIED  -- the element got the focus --
               #IMPLIED  -- the element lost the focus --
  >

Start tag: required, End tag: forbidden

MAP attribute definitions

=
This attribute assigns a name to the image map defined by a element.

AREA attribute definitions

= default|rect|circle|poly
This attribute specifies the shape of a region. Possible values:
  • default: Specifies the entire region.
  • rect: Define a rectangular region.
  • circle: Define a circular region.
  • poly: Define a polygonal region.
= coordinates
This attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations:
  • rect: left-x, top-y, right-x, bottom-y.
  • circle: center-x, center-y, radius. Note. When the radius value is a percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two.
  • poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon.

Coordinates are relative to the top, left corner of the object. All values are . All values are separated by commas.

When set, this boolean attribute specifies that a region has no associated link.

Attribute to associate an image map with an element

=
This attribute associates an image map with an element. The image map is defined by a element. The value of usemap must match the value of the attribute of the associated element.

Attributes defined elsewhere

The element specifies a client-side image map (or other navigation mechanism) that may be associated with another elements (, , or ). An image map is associated with an element via the element's attribute. The element may be used without an associated image for general navigation mechanisms.

The presence of the attribute for an implies that the object being included is an image. Furthermore, when the element has an associated client-side image map, user agents may implement user interaction with the solely in terms of the client-side image map. This allows user agents (such as an audio browser or robot) to interact with the without having to process it; the user agent may even elect not to retrieve (or process) the object. When an has an associated image map, authors should not expect that the object will be retrieved or processed by every user agent.

The MAP element content model allows authors to combine the following:

  1. One or more elements. These elements have no content but specify the geometric regions of the image map and the link associated with each region. Note that user agents do not generally render elements. Therefore, authors must provide alternate text for each with the attribute (see below for information on ).
  2. Block-level content. This content should include elements that specify the geometric regions of the image map and the link associated with each region. Note that the user agent should render block-level content of a element. Authors should use this method to create more accessible documents.

When a element contains mixed content (both elements and block-level content), user agents must ignore the elements.

Authors should specify an image maps's geometry completely with elements, or completely with elements, or completely with both if content is mixed. Authors may wish to mix content so that older user agents will handle map geometries specified by elements and new user agents will take advantage of richer block content.

If two or more defined regions overlap, the region-defining element that appears earliest in the document takes precedence (i.e., responds to user input).

to graphical image maps for cases when graphics are not available or the user cannot access them. For example, user agents may use text to create textual links in place of a graphical image map. Such links may be activated in a variety of ways (keyboard, voice activation, etc.).

Note. is not backwards compatible with HTML 2.0 user agents.

Client-side image map examples

In the following example, we create a client-side image map for the element. We do not want to render the image map's contents when the is rendered, so we "hide" the element within the element's content. Consequently, the element's contents will only be rendered if the cannot be rendered.


   
      The cool site!
   
   
     

Navigate the site: Access Guide | Go | Search | Top Ten

We may want to render the image map's contents even when a user agent can render the . For instance, we may want to associate an image map with an element and include a text navigation bar at the bottom of the page. To do so, we define the element outside the :


   
      The cool site!
   
   
     

...the rest of the page here...

Navigate the site: Access Guide | Go | Search | Top Ten

In the following example, we create a similar image map, this time using the element. Note the use of text:

This is a navigation bar.

Access Guide Search Go Top Ten

Here is a similar version using the element instead of (with the same declaration):

navigation bar

The following example illustrates how image maps may be shared.

Nested elements are useful for providing fallbacks in case a user agent doesn't support certain formats. For example:

text describing the image...

If the user agent doesn't support the PNG format, it tries to render the GIF image. If it doesn't support GIF (e.g., it's a speech-based user agent), it defaults to the text description provided as the content of the inner element. When elements are nested this way, authors may share image maps among them:

Navigate the site: Access Guide | Go | Search | Top Ten

The following example illustrates how anchors may be specified to create inactive zones within an image map. The first anchor specifies a small circular region with no associated link. The second anchor specifies a larger circular region with the same center coordinates. Combined, the two form a ring whose center is inactive and whose rim is active. The order of the anchor definitions is important, since the smaller circle must override the larger circle.


I'm inactive. I'm active.

Similarly, the attribute for the element declares that geometric region has no associated link.

Server-side image maps

Server-side image maps may be interesting in cases where the image map is too complicated for a client-side image map.

It is only possible to define a server-side image map for the and elements. In the case of , the must be inside an element and the boolean attribute () must be set. In the case of , the must be of type "image".

When the user activates the link by clicking on the image, the screen coordinates are sent directly to the server where the document resides. Screen coordinates are expressed as screen pixel values relative to the image. For normative information about the definition of a pixel and how to scale it, please consult .

In the following example, the active region defines a server-side link. Thus, a click anywhere on the image will cause the click's coordinates to be sent to the server.

target

is passed to the server as follows. The user agent derives a new URI from the URI specified by the attribute of the element, by appending `?' followed by the x and y coordinates, separated by a comma. The link is then followed using the new URI. For instance, in the given example, if the user clicks at the location x=10, y=27 then the derived URI is "?10,27".

User agents that do not offer the user a means to select specific coordinates (e.g., non-graphical user agents that rely on keyboard input, speech-based user agents, etc.) should send the coordinates "0,0" to the server when the link is activated.

Visual presentation of images, objects, and applets

All and attributes that concern visual alignment and presentation have been in favor of style sheets.

Attribute definitions

=
Image and object width override.
=
Image and object height override.

When specified, the and attributes tell user agents to override the natural image or object size in favor of these values.

When the object is an image, it is scaled. User agents should do their best to scale an object or image to match the width and height specified by the author. Note that lengths expressed as percentages are based on the horizontal or vertical space currently available, not on the natural size of the image, object, or applet.

The and attributes give user agents an idea of the size of an image or object so that they may reserve space for it and continue rendering the document while waiting for the image data.

White space around images and objects

Attribute definitions

=
This attribute specifies the amount of white space to be inserted to the left and right of an , , or . The default value is not specified, but is generally a small, non-zero length.
=
This attribute specifies the amount of white space to be inserted above and below an , , or . The default value is not specified, but is generally a small, non-zero length.

An image or object may be surrounded by a border (e.g., when a border is specified by the user or when the image is the content of an element).

Attribute definitions

=
This attribute specifies the width of an or border, in pixels. The default value for this attribute depends on the user agent.

Attribute definitions

= bottom|middle|top|left|right
This attribute specifies the position of an , , or with respect to its context.

The following values for concern the object's position with respect to surrounding text:

  • bottom: means that the bottom of the object should be vertically aligned with the current baseline. This is the default value.
  • middle: means that the center of the object should be vertically aligned with the current baseline.
  • top: means that the top of the object should be vertically aligned with the top of the current text line.

Two other values, left and right, cause the image to float to the current left or right margin. They are discussed in the section on .

Differing interpretations of align. User agents vary in their interpretation of the attribute. Some only take into account what has occurred on the text line prior to the element, some take into account the text on both sides of the element.

Attribute definitions

=
For user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the attribute.

Several non-textual elements (, , , and ) let authors specify alternate text to serve as content when the element cannot be rendered normally. Specifying alternate text assists users without graphic display terminals, users whose browsers don't support forms, visually impaired users, those who use speech synthesizers, those who have configured their graphical user agents not to display images, etc.

The attribute must be specified for the and elements. It is optional for the and elements.

While alternate text may be very helpful, it must be handled with care. Authors should observe the following guidelines:

  • Do not specify irrelevant alternate text when including images intended to format a page, for instance, alt="red ball" would be inappropriate for an image that adds a red ball for decorating a heading or paragraph. In such cases, the alternate text should be the empty string (""). Authors are in any case advised to avoid using images to format pages; style sheets should be used instead.
  • Do not specify meaningless alternate text (e.g., "dummy text"). Not only will this frustrate users, it will slow down user agents that must convert text to speech or braille output.

Implementors should consult the section on for information about how to handle cases of omitted alternate text.

阅读(799) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~