HTML The Definitive Guide (130 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
5.55Mb size Format: txt, pdf, ePub

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 display region exactly like the corresponding attributes for the tag. The height and width attributes control the size of the viewing region. The hspace and vspace attributes define a margin around the viewing region.

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.

[The Tag, 5.2.6]

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
tag. [Inline Styles:

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 , while only Internet Explorer supports the name and title attributes. Consequently, to be safe, you should label your objects with both id and name attributes, since the browsers will ignore attributes they do not support. Use a quote-enclosed string for either attribute value.

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 tag generalize that feature to include other object types.

The standard shapes attribute informs the browser that the tag's contents are a series of hyperlinks and shape definitions. The usemap attribute and required URL value point to a where you define the shapes and associated hyperlinks identical to the client-side imagemap we discussed in detail in section
Section 7.5.2, "Client-side Image Maps" in
Chapter 7
.

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 -enclosed contents as well as the direction by which the browser adds the text characters to the display.
[The dir attribute, 3.5.1.1] [The lang attribute, 3.5.1.2]

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

Event Handlers"
.

13.2.1.15 Supporting incompatible browsers
Since some browsers may not support applets or the tag, sometimes you may need to tell readers what they are missing. You do this by including HTML body content between the and tags.

Browsers that support the tags ignore the HTML content inside. Of course, browsers that don't support objects don't recognize the tags. Being generally tolerant of apparent HTML

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 tag if they cannot load, execute, or render the object. If you have several objects of similar intent but with differing capabilities, you can nest their object tags. The browser will try each object in turn, stopping with the first one it can handle. Thus, the outmost object might be a full-motion video. Within that tag, you might include a simpler MPEG video, and within that , a simple GIF image. If the browser can handle full-motion video, your users get the full effect. If that level of video isn't available, the browser can try the simpler MPEG video stream. If that fails, the browser can just display the image. If images aren't possible, that innermost might contain a textual description of the object.

Other books

How to Meet Boys by Clark, Catherine
Invisible Influence by Jonah Berger
Fortune is a Woman by Elizabeth Adler
Heartbreak Bronco by Terri Farley
The Metropolis by Matthew Gallaway
A Four Letter Word by Michelle Lee

© FullEnglishBooks 2015 - 2024    Contact for me [email protected]