<object> (Embedded Object)
This element specifies an arbitrary object to be included in an HTML document. Initially, this element was used to insert ActiveX controls, but according to the specification, an object can be any media object, document, applet, ActiveX control, or even image.
Standard Syntax
<object
align="bottom | left | middle | right | top" (transitional only)</object>
archive="url"
border="percentage | pixels" (transitional only)
class="class name(s)"
classid="id"
codebase="URL"
codetype="MIME Type"
data="URL of data"
declare="declare"
dir="ltr | rtl"
height="percentage | pixels"
hspace="percentage | pixels" (transitional only)
id="unique alphanumeric identifier"
lang="language code"
name="unique alphanumeric name"
standby="standby text string"
style="style information"
tabindex="number"
title="advisory text"
type="MIME Type"
usemap="URL"
vspace="percentage | pixels" (transitional only)
width="percentage | pixels"
param elements and alternative rendering
Attributes Defined by Internet Explorer
accesskey="character"(4)
align="absbottom | absmiddle | baseline | texttop"(4)
code="url"(4)
datafld="column name"(4)
datasrc="id for bound data"(4)
language="javascript | jscript | vbs | vbscript"(4)
unselectable="on | off"(5.5)
Standard Event Attributes
onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup
Events Defined by Internet Explorer
onactivate, onbeforedeactivate, onbeforeeditfocus, onblur, oncellchange, oncontrolselect, ondataavailable, ondatasetchanged, ondatasetcomplete, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onlosecapture, onmove, onmoveend, onmovestart, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onrowenter, onrowexit, onrowsdelete, onrowsinserted, onscroll, onselectstart
Element Specific Attributes
- align
- This attribute aligns the object with respect to the surrounding text. The default is left. The HTML specification defines bottom, middle, right, and top, as well. Browsers might provide an even richer set of alignment values. The behavior of alignment for objects is similar to images. Under the strict HTML and XHTML specifications, the object element does not support this attribute.
- archive
- This attribute contains a URL for the location of an archive file. An archive file typically is used to contain multiple object files to improve the efficiency of access.
- border
- This attribute specifies the width of the object's borders in pixels or as a percentage.
- classid
- This attribute contains a URL for an object's implementation. The URL syntax depends upon the object's type. With ActiveX controls, the value of this attribute does not appear to be a URL but something of the form CLSID: object-id; for example, CLSID: 99B42120-6EC7-11CF-A6C7-00AA00A47DD2.
- code
- Under the old Microsoft implementation, this attribute contains the URL referencing a Java applet class file. The way to access a Java applet under the HTML/XHTML specification is to use <object classid="java: classname.class">. The pseudo-URL java: is used to indicate a Java applet. Microsoft Internet Explorer 4 and beyond support this style, so code should not be used.
- codebase
- This attribute contains a URL to use as a relative base to access the object specified by the classid attribute.
- codetype
- This attribute specifies an object's MIME type. Do not confuse this attribute with type, which specifies the MIME type of the data the object may use, as defined by the data attribute.
- data
- This attribute contains a URL for data required by an object.
- datafld
- This Microsoft-specific attribute is used to indicate the column name in the data source that is bound to the object element.
- datasrc
- The value of this Microsoft-specific attribute is set to an identifier indicating the data source to pull data from.
- declare
- This attribute declares an object without instantiating it. This is useful when the object will be a parameter to another object. In traditional HTML, this attribute takes no value; under XHTML, set it equal to declare.
- height
- This attribute specifies the height of the object in pixels or as a percentage of the enclosing window.
- hspace
- This attribute indicates the horizontal space, in pixels or percentages, between the object and surrounding content.
- name
- Under the Microsoft definition, this attribute defines the name of the control so scripting can access it. Older HTML specifications suggest that it is a name for form submission, but this meaning is unclear and not supported by browsers.
- standby
- This attribute contains a text message to be displayed while the object is loading.
- tabindex
- This attribute takes a numeric value indicating the position of the object in the tabbing index for the document. Tabbing proceeds from the lowest positive tabindex value to the highest. Negative values for tabindex will leave the object out of the tabbing order. When tabbing is not explicitly set, the browser can tab through items in the order they are encountered.
- type
- This attribute specifies the MIME type for the object's data. This is different from the codetype, which is the MIME type of the object and not of the data it uses.
- usemap
- This attribute contains the URL of the image map to be used with the object. Typically, the URL will be a fragment identifier referencing a map element somewhere else within the file. The presence of this attribute indicates that the type of object being included is an image.
- vspace
- This attribute indicates the vertical space, in pixels or percentages, between the object and surrounding text.
- width
- This attribute specifies the width of the object in pixels or as a percentage of the enclosing window or block element.
Examples
<object id="IeLabel1" width="325" height="65"
classid="CLSID:99B42120-6EC7-11CF-A6C7-00AA00A47DD2">
<param name="_ExtentX" value="6879" />
<param name ="_ExtentY" value="1376" />
<param name="Caption" value="Hello World" />
<param name="Alignment" value="4" />
<param name="Mode" value="1" />
<param name="ForeColor" value="#FF0000" />
<param name="FontName" value="Arial" />
<param name="Fontize" value="36" />
<b>Hello World for non-ActiveX users!</b>
</object>
<object classid="java:Blink.class" standby="Here it comes"
height="100" width="300"> <param name="lbl"
value="Java is fun, exciting, and new.">
<param name="speed" value="2">
This will display in non-Java-aware or -enabled browsers.
</object>
<object data="pullinthisfile.html">
Data not included!
</object>
<object data ="pullinthisfile.html">
Data not included!
</object>
Compatibility
HTML 4, 4.01
XHTML 1.0, 1.1, Basic
Internet Explorer 3, 4, 5, 5.5, 6
Netscape 4, 4.5 4.8, 6, 7
Opera 4 7
Notes
Under the strict HTML and XHTML specifications, the object element loses most of its presentation attributes, including align, border, height, hspace, vspace, and width. These attributes are replaced by style sheet rules.
The HTML 4.01 specification reserves the datafld, dataformatas, and datasrc attributes for future use. However, these attributes were dropped in XHTML, though they are well supported by Internet Explorer 4 and beyond.
Alternative content should be defined within an <object> tag after any enclosed <param> tags.
The object element is still mainly used to include multimedia binaries in pages. Although the specification defines that it can load in HTML files and create image maps, not every browser supports this, and few developers are aware of these features. In theory, this very versatile tag should take over duties from the venerable <img> tag in future XHTML specifications.
See Chapter 15 for specific examples of object and an expanded discussion.