References

Beginner-friendly references for web development, with live, editable examples.

The HTML <embed> tag

Element All modern browsers Updated
Quick answer

The HTML <embed> element embeds external content at the given src with its type. It is a void element with no fallback content — for images, media and web pages, prefer <img>, <video> or <iframe>.

Overview

The <embed> element drops external content into the page at a specified point. Unlike <object>, it is a void element — it has no closing tag and therefore offers no fallback content.

Historically it was tied to browser plugins (Flash and similar), which no longer exist in any modern browser. As a result there is almost never a reason to choose it today: use an <img>, <video>, <audio> or <iframe> instead, each of which is better suited to its content and offers fallback or accessibility features that <embed> lacks.

Syntax

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

Attributes

The <embed> element supports the following attributes, in addition to the global attributes available to every HTML element.

Attribute Value Description
height A non-negative integer (pixels). Sets the height of the element in pixels.
src A URL pointing to the resource. Specifies the URL of an embedded resource.
type A MIME type such as text/css or image/webp — or module on a <script>. Specifies the MIME type of a resource.
width A non-negative integer (pixels). Sets the width of the element in pixels.

Example

Live example
<embed src="https://codeshack.io/web/img/icon.png" type="image/png" width="64" height="64">

Best practices

  • Prefer <img>, <video>/<audio> or <iframe> over <embed>.
  • Remember it is a void element with no fallback content.
  • If you must use it, set the type so the browser knows how to handle the resource.
  • Treat it as legacy — its plugin heritage no longer applies in modern browsers.

Frequently asked questions

What is the embed element for?
To embed external content at a point in the page. It is a void element historically associated with browser plugins.
What is the difference between embed and object?
<object> can provide fallback content; <embed> is a void element and cannot.
Should I use the embed element?
Rarely. Modern content is better served by <img>, <video>, <audio> or <iframe>.
Does embed have fallback content?
No. Because it is a void element with no closing tag, it cannot contain fallback content the way <object> can.