HTML <object> tag

The <object> tag is used to display objects such as applets, audio, images, videos, and pdf files on webpages.

Attributes

Attribute Description Possible values
align Sets how text will be aligned around an object left, right, top, bottom
archive A space-separated list of archived URL's that contain resources relevant to the object theURL's
border Sets a border around an object borderSizeNumeric
classid Specifies the location of an object through a URL or as set in the Windows registry theURL or classID
codebase Specifies the URL where to find the object code objCodeURL
codetype Specifies the content type of the object specified by the classid attribute. If codetype is not used, the content type will be set according to the value specified in the type attribute by default. contentType
data Specifies the URL that contains the object's data theURL
declare Specifies that an object should only be declared, not displayed. To later display the object, another <object> tag which refers back to the original object declaration will have to be used. declare
height Sets the object's height numericValue
hspace Sets the horizontal space around an object numericValue
name Sets the object's name. Useful if you are going to refer to the object in scripts objName
standby While an object is loading, the text specified with this attribute will be displayed theText
type Specifies the content type of the data that is specified with the data attribute content type
usemap Specifies the URL of an imagemap to use with an object mapURL
vspace Sets the vertical space around an object numericValue
width Sets the object's width numericValue

Standard attributes

class, dir, id, lang, style, tabindex, title, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup

For more information on event attributes, check out our HTML event attributes reference page.

Example

<object width="320" height="265" data="http://www.youtube.com/v/nQC2Ib5FtcE&hl=en_US&fs=1" type="application/x-shockwave-flash"> See the video: <a href="http://www.youtube.com/watch?v=nQC2Ib5FtcE" target="_blank">Deer drinking water</a> </object>
Output if the object loads:
Output if the object doesn't load:
See the video: Deer drinking water

Tips & notes

You can place alternative content (including other objects) between the <object> and </object> tags that will be displayed if the object does not load.

Use the HTML <param> tag to set the settings for an object like if it should start playing automatically (for an audio object), or if their should be a control panel (for video objects).

Don't use the <object> tag for images, the HTML <img> tag should be used for images.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation