Skip to main content

HTML Tags

HTML <embed> Tag

Written by Updated HTML <embed> Tag exercises

The embed tag puts an outside file into your page, most often a PDF. It is a single tag with no closing tag and no fallback. For video and audio, the dedicated video and audio tags are almost always the better choice.

<embed> was made for browser plugins like Flash. Those are gone, so today it mainly shows what the browser can display on its own: PDFs, images and sometimes media files. A detailed comparison with <object> is in HTML Embed & Object.

Syntax

html

<embed src="filename" type="mime/type" width="600" height="400">

Attributes

AttributeDescription
srcSpecifies the path (URL) of the external file to embed.
typeDefines the MIME type of the embedded content (e.g., video/mp4, application/pdf).
widthSets the width of the embedded content (in pixels).
heightSets the height of the embedded content (in pixels).

Example

Embedding a PDF File

html

<embed src="https://ik.imagekit.io/html5andcss3/lesson-samples/sample.pdf" type="application/pdf" width="700" height="500">

The PDF appears in a box inside the page, using the browser's own PDF viewer with its scroll and zoom controls.

Embedding a Video File

Embedding a Video File

html

<embed src="https://ik.imagekit.io/html5andcss3/lesson-samples/sample_video.mp4" type="video/mp4" width="640" height="360">

This plays the video in some browsers, but the controls and behavior depend entirely on the browser. A <video> tag gives you controls, a poster image, captions and several file formats.

The better way to show a video

html

<video src="sample_video.mp4" controls width="640" height="360"></video>

See HTML Video for the full picture.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Good to know

  • <embed> has no fallback content. If the browser cannot show the file, the box is simply empty. Many phone browsers cannot show PDFs inside a page, so add a normal download link next to it.
  • Always set width and height, so the page does not jump while the file loads.
  • For another web page, use an iframe, not <embed>.

HTML <embed> Tag exercises

Embed a file

Embed this file in the page with the type text/html: https://html5andcss3.org/samples/form.html

Result

Check your answer to see it here.