embed

The HTML <embed> element places external content in a document. This page explains its void-element syntax, its limits, and why a more specific element is often a better choice.

What you will learn

Basic syntax

<embed src="diagram.pdf" type="application/pdf">

embed is a void element, so it must not have a closing tag or child content. The src value identifies the external resource and type can describe its media type.

Prefer a specific element when one exists

Image
Use img with useful alternative text.
Audio or video
Use audio or video with controls and an appropriate fallback.
Another document or interactive page
Consider iframe, object, or a normal link based on the content and trust boundary.

No fallback content inside embed

Unlike object, embed cannot contain fallback markup between an opening and closing tag. If users must still access the content when embedding fails, provide a nearby link or choose an element that supports a useful fallback.

<p>
  <a href="diagram.pdf">Download the diagram as a PDF</a>
</p>
<embed src="diagram.pdf" type="application/pdf">

Security and privacy

Embedding external content gives that resource a place in your page and can affect privacy, performance, and security. Check the source, content type, permissions, and browser behavior. Do not embed untrusted content simply because a URL is available.

Common mistakes

Related pages