💡 Tip: Login now to track your course progress and unlock your downloadable certificates instantly!

HTML Embed & Object

HTML provides the <embed> and <object> elements to include external content in web pages, such as PDFs, multimedia files, or interactive applications. These elements allow you to integrate non-HTML content seamlessly, giving your website rich functionality beyond standard images, audio, or video.

HTML <embed> Element

The <embed> element is used to embed external content directly, such as PDFs, videos, or Flash (legacy). It is a self-closing tag.

Syntax
<embed src="example.pdf" type="application/pdf" width="600" height="400">

Explanation:

  • src: Path or URL of the external file.
  • type: MIME type of the file (e.g., application/pdf, video/mp4).
  • width & height: Size of the embedded content.
HTML Embed Example
<embed src="https://pdfobject.com/pdf/sample.pdf" type="application/pdf" width="600" height="800">

This displays a PDF file directly inside the web page.

HTML <embed> Attributes

AttributeDescription
srcURL or path of the external file to embed.
typeMIME type of the embedded content (e.g., application/pdf, video/mp4).
widthWidth of the embedded content (in pixels or %).
heightHeight of the embedded content (in pixels or %).
autoplayAutomatically starts playing audio or video (if supported).
loopLoops the media (video/audio).
hiddenHides the embedded content from display.
styleCSS styling (can be used to hide sidebars, borders, or adjust appearance).

HTML <object> Element

The <object> element is a more versatile container for external resources, such as PDFs, multimedia, or HTML pages.

HTML Object Syntax
<object data="example.pdf" type="application/pdf" width="600" height="400">
  Your browser does not support embedded objects.
</object>

Explanation:

  • data: Path or URL of the external file.
  • type: MIME type of the file.
  • width & height: Dimensions of the embedded content.
  • Inner content: Fallback text or HTML displayed if the browser cannot load the object.
HTML Object Example
<object data="https://pdfobject.com/pdf/sample.pdf" type="application/pdf" width="600" height="800">
  <p>It appears your browser does not support PDF viewing. <a href="document.pdf">Download the PDF</a>.</p>
</object>

HTML <object> Attributes

AttributeDescription
dataURL or path of the external file.
typeMIME type of the content.
widthWidth of the embedded object.
heightHeight of the embedded object.
formAssociates the object with a form.
nameAssigns a name to the object for scripting purposes.
usemapLinks the object to an image map.
classidIdentifies an ActiveX object (mainly for older IE).
codetypeSpecifies the type of code for the object.

Differences Between <embed> and <object>

Feature<embed><object>
Fallback contentNoneSupported
HTML compatibilityHTML5HTML4 & HTML5
FlexibilityLess flexibleMore flexible
Multimedia supportYesYes
Use for PDFsYesYes

⚠️ Tip: Use <object> if you want fallback content or additional HTML inside the element. Use <embed> for simple embedding.

Removing PDF toolbar/sidebar using parameters in URL

PDF Toolbar Removing Example
<h2>Removing with HTML Embed</h2>
<embed src="https://pdfobject.com/pdf/sample.pdf#toolbar=0&navpanes=0&scrollbar=0" 
       type="application/pdf" 
       width="600" 
       height="500">
<h2>Removing with HTML Object</h2>
<object data="https://pdfobject.com/pdf/sample.pdf#toolbar=0&navpanes=0&scrollbar=0" 
        type="application/pdf" 
        width="600" 
        height="500">
  <p>Your browser cannot display this PDF. <a href="sample.pdf">Download PDF</a></p>
</object>

Explanation:

  • You can control the display of PDF toolbars, navigation panels, and scrollbars by appending parameters in the URL (#toolbar=0&navpanes=0&scrollbar=0).
  • The <object> fallback allows users to download the file if it cannot be displayed.

⚠️ Note: Some PDF viewers ignore certain parameters depending on the browser or plugin.

Advantages

  • Embed multimedia, PDFs, or interactive content directly.
  • <object> allows fallback HTML content.
  • Both elements work across modern browsers for supported formats.
  • Improves user experience without redirecting to external files.

Tips for Embedded Media

  1. Always specify width and height for proper layout.
  2. Test PDF parameters across browsers — some browsers ignore them.
  3. Use fallback content in <object> to maintain accessibility.
  4. For audio/video embedding, use autoplay, loop, muted, and controls attributes as needed.
  5. Combine CSS with <embed> or <object> to style borders or hide scrollbars.

Conclusion

The <embed> and <object> elements allow developers to include rich external content, such as PDFs, multimedia, and interactive applications, directly in web pages.
While <embed> is simpler, <object> is more versatile, especially when fallback content or HTML is needed.
Use these elements to enhance interactivity and functionality on your website.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend