HTML <object> Tag
The HTML <object>
tag represents an embedded object in an HTML document.
Depending on the type of the resource, the <object>
element will either be treated as an image, as a nested browsing context, or as an external resource to be processed by a plugin.
You can use the <param>
tag to pass parameters to plugins that have been embedded using the <object>
tag.
You can also use the <object>
tag to embed another webpage into your HTML document.
Syntax
The <object>
tag is written as <object>
</object>
with any contents enclosed between the start and end tags.
The <object>
tag will usually have one or more attributes, such as the type
attribute, or data
attribute which determine the type of embedded content and any data that is required.
Like this:
The <object>
tag can also have width
and height
attributes to determine the object's width and/or height.
Like this:
Examples
Embed Movie
Here, we use the <object>
element to embed a Quicktime movie into the web page.
Embed Another Webpage
You can use the <object>
element to insert another webpage within your document (this creates a nested browsing context).
Using the <param>
Element
You can use the <param>
element to pass parameters to your embedded objects.
Here, we use the <object>
tag to embed a music file, and the <param>
element to pass parameters to the <object>
element. We tell it not to display audio controls (name="controller" value="true"
) and to start playing automatically (i.e. name="autoplay" value="false
).
Attributes
Attributes can be added to an HTML element to provide more information about how the element should appear or behave.
The <object>
element accepts the following attributes.
Attribute | Description |
---|---|
data | Specifies the location of data to be used by the object. The value must be a valid URL. |
type | Specifies the object type as specified in the data attribute. Must be a valid MIME type. |
typemustmatch | This attribute is used in order to to make it safer for authors to embed untrusted resources where they expect a certain content type. The attribute specifies that the resource specified by the data attribute is only to be used if the value of the type attribute and the Content-Type of the aforementioned resource match.
The The Possible values:
|
name | Assigns the name of the object. |
usemap | Specifies the name of an image map to use on this object. |
form | Specifies the ID of a form to which this object belongs.
Possible values: [The ID of a form element in the element's owner |
width | Specifies the width, in pixels, to display the external content.
Possible values: [Non-negative integer] (for example, |
height | Specifies the height, in pixels, to display the external content.
Possible values: [Non-negative integer] (for example, |
Global Attributes
The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <object>
tag , as well as with all other HTML tags.
accesskey
autocapitalize
class
contenteditable
data-*
dir
draggable
hidden
id
inputmode
is
itemid
itemprop
itemref
itemscope
itemtype
lang
part
slot
spellcheck
style
tabindex
title
translate
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handlers
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.
onabort
onauxclick
onblur
oncancel
oncanplay
oncanplaythrough
onchange
onclick
onclose
oncontextmenu
oncopy
oncuechange
oncut
ondblclick
ondrag
ondragend
ondragenter
ondragexit
ondragleave
ondragover
ondragstart
ondrop
ondurationchange
onemptied
onended
onerror
onfocus
onformdata
oninput
oninvalid
onkeydown
onkeypress
onkeyup
onlanguagechange
onload
onloadeddata
onloadedmetadata
onloadstart
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseout
onmouseover
onmouseup
onpaste
onpause
onplay
onplaying
onprogress
onratechange
onreset
onresize
onscroll
onsecuritypolicyviolation
onseeked
onseeking
onselect
onslotchange
onstalled
onsubmit
onsuspend
ontimeupdate
ontoggle
onvolumechange
onwaiting
onwheel
Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.
For more detail, see HTML event handler content attributes.