Jump to content

XHTML/XHTML Objects

25% developed
From Wikibooks, open books for an open world

In HTML, objects could only be attached to specific image tags or object tags. This changed with XHTML, where these images or resources can be attached to almost any tag.

Images

[edit | edit source]

Images can be explicitly specified with the img tag. XHTML also provides the ability to attach images to span tags as described blow. A significant change from HTML is that there is no longer an alt attribute to describe the image if it cannot load; instead, the content enclosed within the tag pair (if any) is displayed if the resource cannot be loaded.

The src attribute contains a URL to the resource in question. If the resource can be loaded, it replaces the tag with the object itself. Otherwise, the content within the tags is displayed instead. This attribute is used in combination with srctype, which provides information about the resource in question. Typically, it may appear as "image/png" or "image/jpeg".

The encoding attribute identifies the character set of the resource, if it is a text document.

An image can also be used as a navigation map with the usemap attribute, which refers to an id of a navigation list within the element. The <li tags within the navigation list will have the shape and coords elements to specify the details of the navigation map.

Objects

[edit | edit source]

Arbitrary objects within XHTML are declared by the <object tag. The object itself is loaded from the src attribute. If the object is loaded successfully, it will be loaded with the parameters enclosed within the object tag. However, a failure will cause the enclosed to be rendered instead.

The following attributes are used:

Attribute Description
src The source of the object.
srctype The type of object, such as "image/png", "audio/mpeg", or "application/x-java-applet". Other types are possible.
id A unique identifier for the object, if applicable.
archive Provides additional URLs which are related to the object.
content-length Provides the size of the object in question.
declare="declare" If present, causes the object to be loaded after the document finished loading.


Parameters

[edit | edit source]

Within the object tag, parameters can be included to provide information to the loaded object.

The <param> tag uses two base attributes; name which is the name of the parameter, and value which is the content of the parameter. In addition, the param tag can also use valuetype if the parameter's value is a reference (ref) or object (object). Be default, the value type of the parameter is data.

Standby

[edit | edit source]

Content within a <standby> tag is displayed when an object is loading, but hasn't yet finished.

Scripting objects

[edit | edit source]

The <handler> tag indicates a script that handles events within the document. If the browser is unable to load the handler, it will process the content enclosed within the handler tag pair instead, including additional nested handler elements.

With the handler element, the type attribute is mandatory. It describes the scripting language used, such as "text/javascript".