Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<object>, <embed>

Embed an external file — for example, a PDF — using the browser's own viewer.

Syntax

<object data="file.pdf" type="application/pdf">fallback</object>

Attributes

ParameterTypeDescription
dataURLThe file address for `<object>`.
srcURLThe file address for `<embed>`.
typeMIME typeThe file type.
width, heightnumberThe size of the area.

Examples

A PDF with a fallback link:

<object data="/media/menu.pdf" type="application/pdf" width="300" height="150">
  <p>Cannot show the PDF. <a href="/media/menu.pdf">Download the menu</a>.</p>
</object>

The same with <embed> (no fallback content):

<embed src="/media/photo-400x250.jpg" type="image/jpeg" width="200">

Notes

These tags are rarely needed today: images have <img>, video has <video>, pages have <iframe>. The advantage of <object> is that it shows its content when the file cannot be opened. <embed> is single and has no fallback.

See also

  • <iframe> — Embeds another page inside the current one: a map, a video, a widget.
  • <img> — An image.
  • <video> — Embeds a video in the page.

In the tutorial

  • Embedding pages: iframe — The iframe tag — embedding another page, a map or a video, size and title, srcdoc, lazy loading and sandbox restrictions.

Thanks for reading!

Donate to the site — we work hard for you.