<embed> & <object> Tags in HTML

Quick facts

CategoryFlow content, phrasing content, embedded content, palpable content (<object> is also form-associated; <embed> is interactive)
Content model<embed>: empty, it’s a void element. <object>: fallback content, shown if the resource can’t load
Tag omission<embed>: void, no end tag. <object>: neither tag can be omitted
Permitted parentsAny element that accepts embedded content
DOM interfacesHTMLEmbedElement, HTMLObjectElement

Syntax

<object data="guide.pdf" type="application/pdf" width="600" height="400"> <a href="guide.pdf">Download the guide (PDF)</a> </object> <embed src="logo.svg" type="image/svg+xml" width="200" height="80">

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

What about <param>?

The <param> element used to pass settings to browser plugins such as Flash, placed inside an <object>. Plugins are gone from modern browsers, and <param> is now obsolete in the HTML standard, so browsers ignore it. Don’t use it in new pages.

Attributes

<object>

AttributeDescription
dataThe URL of the file to embed
typeThe file’s format, e.g. application/pdf or image/svg+xml
width / heightThe display size in pixels
nameA name for the embedded content, for scripts or link targets
formThe id of a form the object belongs to

<embed>

AttributeDescription
srcThe URL of the file to embed
typeThe file’s format
width / heightThe display size in pixels

Common examples

A PDF with a download fallback

If the browser can’t display the PDF (common on phones), the content inside <object> appears instead.

<object data="/files/menu.pdf" type="application/pdf" width="100%" height="600"> <p>Your browser can't show PDFs. <a href="/files/menu.pdf">Download the menu (PDF)</a>.</p> </object>

An SVG with a PNG fallback

Unlike an <img>, an SVG in <object> can keep its own scripts and links working.

<object data="diagram.svg" type="image/svg+xml" width="400" height="300"> <img src="diagram.png" alt="Diagram of the checkout process"> </object>

Embedding with <embed>

The shortest form. It has no fallback content, so check that the file type is widely supported.

<embed src="/files/brochure.pdf" type="application/pdf" width="100%" height="500">

<embed> / <object> vs <iframe>

<embed> and <object> were designed for plugin content such as Flash, which no longer exists. Today they’re mostly used for PDFs and SVGs. An <iframe> embeds a whole web page — a map, a YouTube video, a form from another site — and has a sandbox attribute to limit what that page can do.

For other websites and embed codes, use an iframe. For a PDF with a fallback link, <object> is a good fit. For images, video and audio, use <img>, <video> and <audio>.

<object><embed><iframe>
Fallback contentYesNoNo
Sandbox optionNoNoYes
Best forPDF, SVGQuick PDF embedWeb pages, embeds

Common mistakes to avoid

  • Embedding Flash, Java or other plugins. Browsers removed plugin support years ago; that content simply won’t show.
  • Embedding a PDF without a download link. Many phones can’t display embedded PDFs, so always offer a link.
  • Missing type. Without it the browser may download the file before knowing whether it can display it.
  • Using embed for video. Use <video>, which has controls, captions and multiple formats.

Accessibility & SEO tips

  • Search engines index PDFs as separate documents, so a plain link to the PDF is often better for SEO than embedding it.
  • Put the most important information on the web page itself in HTML, not only inside an embedded PDF.
  • Give embedded content a title or aria-label so screen reader users know what it is.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions. Plugin content such as Flash no longer works anywhere; PDF display depends on the browser and is often unavailable on phones.

Related tags

Frequently asked questions

How do I embed a PDF in a web page?
Use <object data="file.pdf" type="application/pdf"> with a download link inside as the fallback, or an <iframe>. Many phone browsers won't show PDFs inline at all, so always offer that download link.
Should I still use <embed> or <object> for Flash?
No. Flash and other browser plugins are no longer supported by any modern browser. Use <video>, <audio>, <canvas> or <iframe> for that kind of content today.
What is the difference between <embed> and <object>?
<object> can show fallback content between its tags when the file fails to load, and can belong to a form. <embed> is a single void tag with no fallback. When in doubt, <object> is the safer choice.
Why does my embedded PDF not show on phones?
Many mobile browsers can't display PDFs inside a page. Include a download link as fallback content in <object>, or simply link to the PDF.
Is <embed> deprecated?
No, both <embed> and <object> are valid HTML. They're just rarely needed now that plugins are gone.
Can I embed a YouTube video with <embed>?
Use the <iframe> embed code that YouTube provides instead. It works in all browsers and supports fullscreen and captions.