HTML Tutorial

HTML Tag: <object>

Usage of <object>

The <object> tag embeds external resources (e.g., images, videos, applets) into an HTML document. It provides a generic container for handling various types of content.

Attributes of <object>

  • data: Specifies the URL of the external resource.
  • type: Indicates the MIME type of the embedded content.
  • width: Sets the width of the embedded object.
  • height: Sets the height of the embedded object.
  • name: Assigns a name to the object.

Examples with <object>

  • Embed an image: <object data="image.png" type="image/png"></object>
  • Embed a video: <object data="video.mp4" type="video/mp4"></object>
  • Embed an applet: <object data="myApplet.jar" type="application/x-java-applet"></object>

Exploring the <object> Tag: HTML Code:

<!DOCTYPE html>
<html>
<body>
  <object data="image.png" type="image/png" width="200" height="100">
    <p>This is an image.</p>
  </object>
</body>
</html>

Result:

An image is displayed within the web page. If the image fails to load, the "This is an image" text will appear instead.