W3docs

HTML <embed> Tag

The <embed> tag is used to embed the content, which is not understood by the browser. Description, attributes and examples.

The <embed> tag is used as a container for external applications, multimedia and interactive content that the browser doesn’t understand. External plug-ins or special programs must be installed or enabled for proper display. The display of the embedded content depends on the file type, the attributes of the <embed> tag, and the plugins installed in the browser. For modern web development, it is recommended to use the <video> and <audio> tags instead of the <embed> tag.

To load objects into HTML4, use the <object> tag. For broader compatibility, the <embed> tag is often placed inside the <object> tag. In HTML5, <embed> is a standard element, so documents using it validate correctly.

Tip

Use the CSS object-position property to correct the positioning of the embedded object within the element’s frame.

Syntax

The <embed> tag is empty, which means that the closing tag isn’t required. But in XHTML, the <embed> tag must be closed (<embed/>).

Example of the HTML <embed> Tag

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <embed src="/uploads/media/default/0001/01/0710cad7a1017902166203def268a0df2a5fd545.png" />
  </body>
</html>

Result

embed tag example

Example of the HTML <embed> tag for placing an audio:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <embed type="audio/mpeg" 
      src="/build/audios/audio.mp3" 
      width="200"
      height="100" />
  </body>
</html>

Example of the HTML <embed> tag for placing a video:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <embed type="video/mp4" 
      src="/build/videos/arcnet.io(7-sec).mp4" 
      width="300" 
      height="200" 
      title="Arcnet.io video" />
  </body>
</html>

Attributes

AttributeValueDescription
alignleft, right, center, justifySpecifies the alignment of the embedded content on the page and the way it is wrapped around the text.
heightpixelsDefines the height of the embedded content.
pluginspageURLAddress, from where we can download and install necessary plug-in.
srcURLIndicates the path to the file which will be inserted in the <embed> tag.
typeMIME-typeDefines the MIME type (specification for the transmission over the network of files of various types) of the embedded content.
vspacepixelsDefines the vertical indent from the embedded content to the surrounding one.
widthpixelsDefines the width of the embedded content.

The <embed> tag supports the Global attributes and the Event Attributes.

Note: The align and vspace attributes are obsolete in HTML5. For modern styling and layout, it is recommended to use CSS width, height, and object-position properties instead of the HTML attributes.

Practice

Practice

What are the use-cases of the HTML <embed> tag?