<object> Tag in HTML
The <object> tag in HTML is used to embed multimedia files, such as PDFs, videos, audio files, and other web applications into a webpage. It allows for flexible handling of external resources.
Key Points on <object> Tag:
- The <object> tag can embed multimedia files or other web applications.
- The data attribute specifies the URL of the resource to be embedded.
- The type attribute defines the media type of the embedded file.
- The width and height attributes set the dimensions of the embedded resource.
- If the browser does not support the embedded resource, content between the
<object>
tags is displayed instead.
Syntax of <object> Tag:
Syntax Example
<object data="URL" type="media_type" width="width" height="height">
Alternate content for unsupported browsers
</object>
Example of <object> Tag in HTML:
This example demonstrates how to embed a PDF file using the <object>
tag.
Code Example
<object data="sample.pdf" type="application/pdf" width="600" height="400">
Your browser does not support PDFs. Please download the PDF to view it:
<a href="sample.pdf">Download PDF</a>.
</object>
Output
Using <object> Tag for Embedding a Video:
This example shows how to embed a video file using the <object>
tag.
Code Example for Video
<object data="sample.mp4" type="video/mp4" width="640" height="360">
Your browser does not support the video tag.
<a href="sample.mp4">Download the video</a>.
</object>
Output for Video
The <object>
tag is highly versatile for embedding various types of multimedia and web applications directly into a webpage. It provides an alternative display option if the resource is unsupported by the browser.