HTML - <object> Tag



The <object> tag in HTML is used to show multimedia on web pages, including audio, video, pictures, webisite, PDFs, and Flash.

Additionally, another website may be displayed inside the HTML page using this technique.

To define various parameters, the <param> tag is additionally used with this tag. Any text contained between the <object> tags is considered as alternative text, which is displayed when the browser does not support the data supplied.

Syntax

<object data="" type=""></object>

Attribute

HTML summary tag supports Global and Event attributes of HTML. Acceppts some specific attributes as well which are listed below.

Attribute Value Description
data URL Specify the url of resorce which will be used into object.
form form_id Specify the belging form of the object.
height pixels Define the height of the object.
name name specify the name of the object.
type media_type Specifies the media type of data specified in the data attribute
width pixels Define the width of the object.

Examples of HTML object Tag

Bellow examples will illustrate the usage of object tag. Where, when and how to use object tag to object image, html page, video or audio.

Embeding image using object Tag

Let’s look at the basic example where we are going to use an image on the webpage. We recomend you to use <img> tag to display images.

<!DOCTYPE html>
<html>

<head>
    <title>HTML object Tag</head>
</head>

<body>
    <object data="/html/test.jpg" type="text/html" width="300" height="200"> 
       alt : <a href="/html/images/logo.png">test.jpg</a>
    </object>
</body>

</html>

Embeding video using object Tag

Consider another scenario where we are going to use the HTML <embed> tag to use a video. We recomend you to use <video> tag to display video.

<!DOCTYPE html>
<html>

<head>
    <title>HTML object Tag</head>
</head>

<body>
       <object height="250" width="500"
               data=
"https://cdn.pixabay.com/vimeo/497754241/laptop-61037.mp4?width=640&hash=d25d7f4b8afa862b3252bdaeaf157934ceb1bb72">
       </object>
</body>

</html>

Embeding html page using object Tag

Consider another scenario where we are going to use the HTML <embed> tag to use a html page. We recomend you to use <iframe> tag to display html page.

<!DOCTYPE html>
<html>

<head>
    <title>HTML object Tag</head>
</head>

<body>
    <object data="index.htm" width="500" height="200">
</body>

</html>

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
embed Yes Yes Yes Yes Yes
html_tags_reference.htm
Advertisements