The <object> tag specifies an embedded object within an HTML document. It is generally used for embedding multimedia (audio, video, Java applets, Flash applications, etc.) or another HTML document into the web page.
You can include alternative text in the <object> tag that will be shown if browsers don’t support this tag.
You can use the <param> tag to pass parameters to plugins that have been embedded using the <object> tag.
For images, the <img> tag can be used instead of the <object> tag. You should define at least one of the type or data attributes.
Syntax
The <object> tag comes in pairs. The content is written between opening (<object>) and closing (</object>) tags. The <object> tag is used as a child element of <body>.
Example of the HTML <object> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the webpage</title>
</head>
<body>
<p>Steve Jobs' Stanford Commencement Address - YouTube</p>
<object width="320" height="240" data="https://www.youtube.com/embed/bZNEB_o3Hzw?ecver=2">
</object>
</body>
</html>
Attributes
Attribute | Value | Description |
---|---|---|
align | top bottom middle left right |
Specifies the alignment of the content inside <object> element according to surrounding elements.
Not supported in HTML 5. |
archive | URL | Defines a list of URLs to archives containing resources relevant to the object. Not supported in HTML5. |
border | pixels | Sets the width of the border around an <object>. Not supported in HTML5. |
classid | URL | Sets the URL of the object's implementation. It can be used together with, or instead of, the data attribute.
Not supported in HTML5. |
codebase | URL | Defines the path used to resolve relative URIs specified by classid, data, or archive. If not specified, the default is the base URI of the current document.
Not supported in HTML5. |
codetype | media_type | Sets media type of the code referred to by the classid attribute.
Not supported in HTML5. |
data | URL | Sets the URL of the resource that will be used by the object. |
declare | declare | Specifies that the object should only be declared. Not supported in HTML5. |
form | form_id | Specifies one or more forms <object> belongs to. |
height | pixels | Specifies the height of the object. |
hspace | pixels | Specifies the whitespace on the left and right sides of an object.
Not supported in HTML5. |
name | name | Specifies a name for the object. |
standby | text | Specifies a text to be displayed while the object is loading.
Not supported in HTML5. |
tabindex | number | Sets the position of an element in the tabbing navigation order for the current document. |
type | media_type | Specifies the media type of data specified in the data attribute. |
usemap | #mapname | Specifies the name of a client-side image map to be used with the object (a hash-name reference to the <map> element). |
vspace | pixels | Sets the whitespace on top and bottom of an object.
Not supported in HTML5. |
width | pixels | Set the width of an object. |
The <object> tag also supports the Global attributes and the Event Attributes.
Browser support
✓ | ✓ | ✓ | ✓ | ✓ |
Practice Your Knowledge
Quiz Time: Test Your Skills!
Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.