HTML - <object> Tag



The <object> tag in HTML is used to show multimedia on web pages, including audio, video, pictures, 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

Following is the syntax of <object> tag −

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

Specific Attributes

The HTML <object> tag also supports the following additional attributes −

S.No. Attribute & Description
1

align

Defines visual alignment of the object
2

archive

A space separated list of URL's to archives.
3

border

Specifies border width around the object
4

classid

Defines a class ID value as set in the Windows Registry or a URL
5

codebase

Specifies the path where object code is located.
6

codetype

The internet media type of the code referred to by the classid attribute.

Example

Let’s look at the following example, where we are going to embed an image.

<!DOCTYPE html>
<html>
<head>
   <title>HTML object Tag</title>
</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>

When we execute the above code, it will generate an output consisting of the image uploaded to the webpage.

Example

Consider another scenario where we are going to embed a video on the webpage.

<!DOCTYPE html>
<html>
<head>
   <title>Object Tag</title>
</head>
<body>
   <h2>Embedding the video</h2>
   <object height="250" width="500" data="https://cdn.pixabay.com/vimeo/497754241/laptop-61037.mp4?width=640&hash=d25d7f4b8afa862b3252bdaeaf157934ceb1bb72"></object>
</body>
</html>

On running the above, an output window will pop up consisting of the video along with text displayed on the webpage.

html_tags_reference.htm
Advertisements