September 06, 2024
How to embed Files on a web page?How to embed Files on a web page?
- Embedding files on a webpage means including content from another source, like a video, PDF, or another webpage, directly into your own webpage. HTML provides several tags for embedding content, including <iframe>, <object>, and <embed>.
1. <iframe>: Embedding Another Web Page
An <iframe> allows you to embed another HTML document within your webpage. It's like putting one webpage inside another.
<iframe src="https://toforzero.com" width="600" height="300"></iframe>
- src: The URL of the webpage you want to embed.
- width and height: Control the size of the embedded content.
- In this example, the webpage from "https://toforzero.com" will be displayed inside a 600 x 300 pixel area on your page.
- <iframe> is Best for embedding another web page, like a YouTube video or Google Maps.
2. <object>: Embedding Files like PDFs
- The <object> tag is a versatile way to embed different types of content, including PDFs, videos, or even other webpages.
- <object> is Good for embedding complex content like PDFs, multimedia files, or even entire webpages. It provides more control and flexibility.
<object data="document.pdf" type="application/pdf" width="600" height="400">
<p>Your browser does not support this website. Please download the PDF to view it:
<a href="./pdf/Adobe vs edu.pdf" download="true">Download PDF</a>.
</p>
</object>
- data: The URL of the file you want to embed.
- type: The MIME type of the content (e.g., application/pdf for PDFs).
- Fallback Content: The content inside the <object> tag is displayed if the embedded file can't be shown.
3. <embed>: Embedding Media like Videos and PDFs
- The <embed> tag is used for embedding content like videos, PDFs, or Flash applications. It's similar to <object>, but it's simpler and often used for more straightforward cases.
<embed src="video.mp4" width="600" height="400" type="video/mp4">
- src: The URL of the file you want to embed.
- type: The MIME type of the content (e.g., video/mp4 for MP4 videos).
- <embed> is used for embedding simple media files like videos or Flash applications. It's more straightforward but less flexible than <object>.
html
iframe
object
embed