Read HTML The Definitive Guide Online
Authors: Chuck Musciano Bill Kennedy
For example, here is an image included as an object, rather than as an file:
13.2.1.6 The type attribute
The type attribute lets you explicitly define the MIME type of the data that appear in the file you declare with the data attribute. (Use codetype to indicate an applet's MIME type.) If you don't provide data, or if the MIME type of the data is apparent from the URL or is provided by the server, you may omit this attribute. We recommend you include it anyway, to ensure that your data is handled correctly by the browser and the included object.
For examples of data MIME types, look in your browser preferences for applications. There you'll find a list of the many file data types your browser will recognize and the application, if not the browser itself, that will process and render that file type.
13.2.1.7 The align, class, border, height, hspace, style, vspace, and width attributes
There are several attributes that let you control the appearance of the
The value for each of these dimension attributes should be in pixels.
The align attribute (deprecated in the HTML 4.0 standard here as well as for and all other tags in lieu of style sheets) determines how the browser aligns the region in context with the surrounding text.
Use top, texttop, middle, absmiddle, baseline, bottom, or absbottom to align the object display space with adjacent text, or left and right alignments for wraparound content.
The display region's dimensions often must match some other applet requirement, so be careful to check these values with the applet programmer. Sometimes, the applet may scale its display output to match your specified region.
For example, suppose our example clock applet should grow or shrink to fit nearly any size display region. Hence, we might create a square clock 100×100 pixels:
As with , use the border attribute to control the width of the frame that surrounds the object's display space when you include it as part of a hyperlink. The null value (border=0) removes the frame.
Use the class and style attributes, of course, to control the display style for the content enclosed by the tag, and to format the content according to a predefined class of the
The style Attribute, 9.1.1]
[Style Classes, 9.2.4]
13.2.1.8 The declare attribute
The declare attribute lets you define an object, but restrains the browser from downloading and processing it. Used in conjunction with the name attribute, this facility is similar to a forward declaration in a more conventional programming language that lets you defer download of an object until it actually gets used in the document.
13.2.1.9 The id, name, and title attributes
Use the id and name attributes to uniquely label an object. Use the title attribute to simply entitle the tag. Each attribute's value is a text string. The browser may choose to display a title to the user or may use it in some other manner while rendering the document. Use id and name to reference the object in other elements of your HTML document, including hyperlinks and other objects.
For example, suppose you have two clock applets in your document, along with two applets the user operates to set those clocks. Provide unique labels for the clock applets using the name or id attribute, then pass those labels to the setting applets using the tag, which we discuss later in this chapter:
Since we have no need to distinguish between the setter applets, we choose not to name their instances.
Currently, only Netscape supports the id attribute for
13.2.1.10 The shapes and usemap attributes
Recall from our detailed discussion of hyperlinks in Chapter 7, Links and Webs
, that you can divide a picture into geometric regions and attach a hyperlink to each, creating a so-called image map. The shapes and usemap attributes for the
The standard shapes attribute informs the browser that the
For example, here is the image map we described in
Chapter 7
, rewritten as a "shaped" object:
and as the more familiar image map:
...
You also may take advantage of all the attributes associated with the hyperlink, map, and tags to define and arrange the image map regions. For instance, we recommend that you include alternative (alt attribute) text descriptions for each sensitive region of the image map.
13.2.1.11 The standby attribute
The standby attribute lets you display a message - the attribute's value text string - during the time the browser is downloading the object data. If your objects are large or if you expect slow network response, add this attribute as a courtesy to your users.
13.2.1.12 The tabindex and notab attributes
For Internet Explorer with ActiveX objects only, the notab attribute excludes the object from the document tabbing order.
As an alternative to the mouse, users also may press the Tab key to select and the Return or Enter key to activate a hyperlink or to access a form control. Normally, each time the user presses the Tab key, the browser steps to the next hyperlink or form control in the order that they appear in the document. Use the HTML 4.0-standard tabindex and an integer value to modify the position the object occupies in the sequence of tab-selected elements on the HTML page.
13.2.1.13 The dir and lang attributes
Use the dir and lang attributes, like their counterparts for most other HTML 4.0 standard tags, to specify the language and dialect of the
13.2.1.14 Object event handling
As user-initiated mouse and keyboard events occur within the object, you may want to perform special actions. Accordingly, you can use the ten standard event attributes to catch these events and execute JavaScript code. We describe JavaScript event handlers more fully in section
Section 13.3.3, "JavaScript
13.2.1.15 Supporting incompatible browsers
Since some browsers may not support applets or the
Browsers that support the
mistakes, they will usually ignore the unrecognized tag and blithely go on to display whatever content may appear inside. It's as simple as that. The following fragment tells object-incapable browser users they won't see our clock example:
If your browser were capable of handling applets, you'd see a nifty clock right here!
More importantly, object-capable browsers will display the contents of the