Signup/Sign In
PUBLISHED ON: FEBRUARY 19, 2021

HTML Object Tag

In HTML, the <object> tag can be used to represent an external resource or it is used to define embedded objects inside an HTML Document.

  • The external resource can be any image, any nested browsing context, or it can be any resource handled by the plugin.

  • This tag is used inside the <body> tag.

  • Those browsers not supporting <object> tag will take the text inside <object> and </object> as an alternative text.

  • Objects are mainly used in forms and in the submission of forms.

  • To embed another web page into your document you can also use a <object> tag.

  • Also, this is an Inline Element.

HTML <object> Tag Syntax and Usage

The <object> tag requires both opening (start) tag and closing(end) tag.

The Basic syntax for the same is given below:

<object>
...content here
</object>

HTML <object> Tag Attributes

The <object> tag supports both global and event attributes and some of the common attributes are given below:

1. Data

This attribute is used to specify the address of the resource as a valid URL.

2. Form

This attribute is used to specify the form to which the object belongs to.

3. Height

This height attribute in <object> tag is used to specify the height of the object in pixels.

4. Type

This attribute is used to specify the content type of the resource specified by the data.

5. Width

This attribute is used to specify the width of an object in pixels.

6. Usemap

This attribute is used to specify a hash-name reference to the map element.

HTML <object> Tag Basic Example

Below we have a basic example For the <object> as:

<html>
<head>
<title>
Object tag example
</title>
</head>
<body>
<object type="application/pdf"
    data="/media/examples/abc.pdf"
    width="250"
    height="200">
</object>
</body>
</html>

Default CSS Settings for HTML <object> Tag

Most of the browsers use default CSS settings for <object> tag and it is given below:

object:focus {
  outline: none;
}

Browser Support for HTML <object> Tag

Following browsers support this attribute:

  • Google Chrome 1+

  • Internet Explorer 3+

  • Safari 1+

  • Firefox 1+

  • Opera 4+



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.