Description
The HTML element <object>
is used to define an embedded object within an HTML document.
The embedded object can be of any type like a video, audio, PDF document, Flash animations, Java Applets, ActiveX, images, another web page, etc.,
The below table summarizes its usage.
Usage Details | |
Placement | It is defined as a Block element. |
Contents | It can contain Block elements, Inline elements, and text. In case it contains the <param> element, it must come first. |
Tags | Both the opening and closing tags are required. |
Versions | HTML 4, 4.01, 5 |
Syntax
Here is the basic syntax of the <object>
element.
- It is always recommended to use the
type
attribute whendata
is provided, as it allows the browser to avoid loading unsupported content types.
<object data="URL" type="content-type">...</object>
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element object</title>
</head>
<body>
<object type="application/x-shockwave-flash">
<param name="movie" value="/assets/videos/play.swf">
</object>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <object>
element.
Attribute Type | Details |
Element-Specific Attributes | The tag <object> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <object> supports the HTML Global Attributes. |
Event Attributes | The tag <object> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <object>
element.
- One of the required attributes must be specified for the element to be valid.
Attribute | Value | Required | Description |
data |
URL | Yes | Specifies the location of the data or file that the object requires. |
type |
content-type | Yes | Specifies the content-type of the resource specified by data attribute. |
align |
left, right, top, middle, bottom |
No | Obsolete Use CSS instead. Specifies the alignment of the <object> element with respect to the surrounding content. |
archive |
URLs | No | Obsolete A space-separated list of URLs to archives containing resources relevant to the object. |
border |
pixels | No | Obsolete Specifies the width of the border around the object. Use the CSS border property instead. |
classid |
URI | No | Obsolete Defines the URL or internal reference for the object's implementation. |
codebase |
URI | No | Obsolete Specifies the base path used to resolve relative URLs specified by the classid , data , and archive attributes. |
codetype |
content-type | No | Obsolete Specifies the content-type of data expected when downloading the object specified by classid attribute. |
declare |
declare |
No | This boolean attribute specifies that the object should only be declared but not instantiated. |
form |
form-id | No | Specifies the form that the object element is associated with i.e. its "form owner". |
height |
length | No | Sets the object's height. |
hspace |
pixels | No | Obsolete Specifies the amount of whitespace on the left and right sides of an object. |
name |
text | No | Specifies the name of the object. |
standby |
message | No | Obsolete Specifies a text message to be displayed while the object is loading. |
usemap |
URL | No | Defines a client-side image map associated with an image object element. |
vspace |
pixels | No | Obsolete Specifies the amount of whitespace on the top and bottom sides of an object. |
width |
length | No | Sets the object's width. |
Browser Compatibility
The tag <object>
is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 3+
- Firefox 1+
- Apple Safari 1+
- Opera 4+