HTML5 Reference

HTML <object> tag

Definition

The <object> tag is used to define an embedded object in our HTML using an external resource.

the external resource can be another HTML document, an image, a media player, or a plug-in application.

In most situations there are more appropriate HTML tags available which should be used instead:-

For inlining HTML documents use the <iframe> tag.

For images use the <img> tag.

For processing audio files use the <audio> tag.

For processing video files use the <video> tag.

Example


<object data="../../pages/apple.html" 
  type="text/html" 
  width="300" 
  height="200">
</object>

Attributes

The following attributes can be used with the <object> tag.


<object> Specific Attributes
Attribute Value Description Example
dataurlSpecifies the URL location of the objects data.

<object data="../../pages/apple.html"></object>
heightnumberSpecifies the height of the object in pixels.

<object height="300"></object>
namenameSpecifies a name for the object.

<object data="../../pages/apple.html" 
        name="someName"></object>
typemedia-typeSpecifies the content type of the data in the data attribute.

Must be a valid MIME type.

<object type="application/pdf"></object>
typemustmatchnumberSpecifies that resource specified in the data attribute should only be used if the content type in that attribute matches the content type of the type attribute.

<object data="../../pages/apple.html" 
        type="application/pdf
        typemustmatch="typemustmatch"></object>
usemapmapNameSpecifies a client side map image to be used on the object.

<object usemap="mapName"></object>
widthnumberSpecifies the width of the object in pixels.

<object width="250"></object>
<object> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<object class="name"></object>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<object id="name"></object>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<object style="color:red;"></object>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<object title="Content info"></object>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<object accesskey="a"></object>
tabindexSpecifies a tab order for the element.

<object tabindex="1"></object>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<object dir="ltr"></object>
<!-- The text will flow from right to left -->
<object dir="rtl"></object>
langSpecifies a language code for the content of the element.

<object lang="en"></object>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited/browser specific. -->
<object spellcheck="true"></object> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<object translate="no"></object> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<object contenteditable="true"></object> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<object draggable="true"></object>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<object hidden></object> 
<object hidden="hidden"></object> 
<object> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<object oncopy="go()"></object> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<object oncut="go()"></object>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<object onpaste="go()"></object>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<object ondrag="go()"></object>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<object ondragend="go()"></object>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<object ondragenter="go()"></object>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<object ondragleave="go()"></object>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<object ondragover="go()"></object>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<object ondragstart="go()"></object>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<object ondrop="go()"></object>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<object onblur="go()"></object>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<object onchange="go()"></object>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<object oncontextmenu="go()"></object>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<object onfocus="go()"></object>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<object oninput="go()"></object>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<object oninvalid="go()"></object>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<object onreset="go()"></object>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<object onselect="go()"></object>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<object onsubmit="go()"></object>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<object onkeydown="go()"></object>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<object onkeypress="go()"></object>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<object onkeyup="go()"></object>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<object onabort="go()"></object>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<object oncanplay="go()"></object>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<object oncanplaythrough="go()"></object>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<object oncuechange="go()"></object>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<object ondurationchange="go()"></object>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<object onemptied="go()"></object>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<object onended="go()"></object>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<object onloadeddata="go()"></object>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<object onloadedmetadata="go()"></object>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<object onloadstart="go()"></object>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<object onpause="go()"></object>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<object onplay="go()"></object>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<object onplaying="go()"></object>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<object onprogress="go()"></object>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<object onratechange="go()"></object>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<object onseeked="go()"></object>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<object onseeking="go()"></object>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<object onstalled="go()"></object>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<object onsuspend="go()"></object>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<object ontimeupdate="go()"></object>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<object onvolumechange="go()"></object>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<object onwaiting="go()"></object>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<object onclick="go()"></object>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<object ondblclick="go()"></object>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<object onmousedown="go()"></object>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<object onmousemove="go()"></object>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<object onmouseout="go()"></object>>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<object onmouseover="go()"></object>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<object onmouseup="go()"></object>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<object onwheel="go()"></object>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<object onscroll="go()"></object> 
Window - NONE

Relevant HTML Tutorials

HTML Lessons - Embedding