object Tag in HTML

0
118

The HTML <object> tag is used to embed external resources such as images, videos, audio, and other web pages into an HTML document. In this tutorial, we will cover the basics of the <object> tag and how to use it to display external resources.

Syntax:
The basic syntax of the <object> tag is as follows:

<object data=”url_of_external_resource” type=”type_of_external_resource”></object>

Attributes:
The <object> tag has several attributes that can be used to specify the behavior and properties of the external resource. Here are some commonly used attributes:

– data: This attribute specifies the URL of the external resource that you want to embed.
– type: This attribute specifies the MIME type of the external resource. The MIME type is used to identify the type of data that is being embedded, such as an image, video, or audio file.
– width: This attribute specifies the width of the embedded resource in pixels.
– height: This attribute specifies the height of the embedded resource in pixels.
– name: This attribute specifies a name for the embedded resource.
– classid: This attribute specifies the class ID of the object to be embedded. This is used to identify the type of object, such as an ActiveX control.
– codebase: This attribute specifies the base URL for the object to be embedded. This is used to specify the location of the object’s installation files.

Also Read:  figcaption Tag in HTML

Example:
Here is an example of how to use the <object> tag to embed an image into an HTML document:

<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Embedded Image Example</h1>
<object data=”https://www.example.com/image.jpg” type=”image/jpeg” width=”400″ height=”300″></object>
</body>
</html>

In this example, we are embedding an image with the URL “https://www.example.com/image.jpg” into the HTML document. The type attribute specifies that it is a JPEG image file. The width and height attributes specify the dimensions of the image in pixels.

Conclusion:
The <object> tag is a powerful tool for embedding external resources into an HTML document. By using this tag, you can easily display images, videos, audio, and other web pages without having to write complex code. With the help of the attributes, you can control the behavior and properties of the embedded resource.

Leave a Reply