XHTML Reference: object

The XHTML WYSIWYG Editor For Desktop & Web Applications

object

Definition

The object element provides a generic way of embedding objects such as images, movies and applications (Java applets, browser plug-ins, etc.) into Web pages. param elements contained inside the object element are used to configure the embedded object. Besides param elements, the object element can contain alternate content which can be text or another object element. Alternate content serves as a fall-back mechanism for browsers that are unable to process the embedded object.

Example

The following is an example of an image used as an embedded object. If the image cannot be loaded, alternate content found within the object element will be rendered instead.

  1. <p>
  2. <object data="images/headshot.gif" type="image/gif" width="150" height="100">
  3. Photo: John Smith, Director of <abbr>IT</abbr>
  4. </object>
  5. </p>

Below is an example of how to embed a Flash object and configure it using param elements. An image is used as alternate content.

  1. <p>
  2. <object type="application/x-shockwave-flash" width="600" height="400">
  3. <param name="movie" value="movies/mars.swf" />
  4. <param name="menu" value="false" />
  5. <param name="quality" value="high" />
  6. <img src="images/mars.jpg" alt="Photo: Galle Crater taken from the Mars Express spacecraft" />
  7. </object>
  8. </p>

Best practice

Though the object element is an inline element, it may contain block elements. Since this can create nonsensical nesting, it is recommended to use only inline elements as alternate content for an object element.

Attributes

Note: Implementation of some of the following attributes varies between Web browsers and browser plug-ins. If you are using a browser plug-in, contact the plug-in vendor to obtain markup examples to load the plug-in.

Basic

classid
(URI) 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 data attribute, depending on the type of object involved. For example: clsid:D27CDB6E-AE6D-11cf-96B8-444553540000.
codebase
(URI) This attribute specifies the base path used to resolve relative URIs specified by the classid, data, and archive attributes. When absent, its default value is the base URI of the current document. Some Web browser like Internet Explorer use this attribute to point to CAB or INF files in order to download the object.
height
(Length) Object height.
name
(Text) When the object is used as a form control, this attribute is the name of the form control.
type
(ContentType) This attribute specifies the content type for the object. This attribute may be used with or without the data attribute. Most Web browsers use this attribute (instead of classid) to determine how to process the object. For example: application/x-shockwave-flash.
width
(Length) Object width.

Advanced

archive
(URIs) This attribute may be used to specify a space-separated list of URIs for archives containing resources relevant to the object.
codetype
(ContentType) This attribute specifies the content type of data expected when downloading the object specified by classid.
data
(URI) 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.
declare
When present, this attribute makes the current object definition a declaration only. This means another object element will be used to load the object. Possible value is declare.
standby
(Text) This attribute specifies a message that a Web browser may display while loading the object.
tabindex
(Number) Position in tabbing order.
usemap
(IDReference) This attribute associates the object to a client-side image map defined by a map element. The value of this attribute must match the id attribute of the map element.

Common core attributes

class
(NameTokens) This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or set of class names. Multiple class names must be separated by white space characters. Class names are typically used to apply CSS formatting rules to an element.
id
(ID) This attribute assigns an ID to an element. This ID must be unique in a document. This ID can be used by client-side scripts (such as JavaScript) to select elements, apply CSS formatting rules, or to build relationships between elements.
title
(Text) This attribute offers advisory information. Some Web browsers will display this information as tooltips. Assistive technologies may make this information available to users as additional information about the element.

Common internationalization attributes

xml:lang
(NameToken) This attribute specifies the base language of an element's attribute values and text content.
dir

This attribute specifies the base direction of text. Possible values:

  • ltr: Left-to-right
  • rtl: Right-to-left

Common event attributes

onclick
(Script) A client-side script event that occurs when a pointing device button is clicked over an element.
ondblclick
(Script) A client-side script event that occurs when a pointing device button is double-clicked over an element.
onmousedown
(Script) A client-side script event that occurs when a pointing device button is pressed down over an element.
onmouseup
(Script) A client-side script event that occurs when a pointing device button is released over an element.
onmouseover
(Script) A client-side script event that occurs when a pointing device is moved onto an element.
onmousemove
(Script) A client-side script event that occurs when a pointing device is moved within an element.
onmouseout
(Script) A client-side script event that occurs when a pointing device is moved away from an element.
onkeypress
(Script) A client-side script event that occurs when a key is pressed down over an element then released.
onkeydown
(Script) A client-side script event that occurs when a key is pressed down over an element.
onkeyup
(Script) A client-side script event that occurs when a key is released over an element.

Common style attribute

style
(Text) This attribute specifies formatting style information for the current element. The content of this attribute is called inline CSS. The style attribute is deprecated (considered outdated), because it fuses together content and formatting.

Contains

Further reading