Definition
The <embed>
tag is used to embed external resources into an HTML document, such as an image, web page, audio file, or video file.
Example
<!--Embed an imgsrc:-->
<embed
type="image/jpg"
title="storm"
src="https://res.cloudinary.com/thewebmaster/image/upload/ar_16:10,c_fill,f_auto,g_auto,q_auto,w_300/image/google-update-march-2017.jpg"
width="300"
height="188"
/>
<!--Embed a HTML page:-->
<embed
type="text/html"
title="The Webmaster"
src="https://www.thewebmaster.com/"
width="500"
height="200"
/>
<!--Embed a movie file:-->
<embed type="video/webm"
src="https://file-examples-com.github.io/uploads/2020/03/file_example_WEBM_1920_3_7MB.webm"
width="250"
height="200"
title="The Earth"
/>
Usage
- For the
<embed>
element to display correctly, you will need to add thetype
,src
,width
, andheight
attributes. - The
<embed>
element must have an opening tag but must not have a closing tag. - Most browsers no longer support Java Applets and Plug-ins, ActiveX controls, or Flash.
Attributes
The <embed>
element supports the Global Attributes, as well as the following.
height
The
height
attribute specifies the height in px of the embedded resource.width
The
width
attribute specifies the width in px of the embedded resource.src
The
src
attribute specifies the address of the embedded resource.type
The
type
attribute specifies the MIME type of the embedded resource.
Best Practices
- While using
<embed>
tags to embed images, html documents, video, and audio is perfectly valid HTML5, it is better to use other semantic elements. For example: - There is better support in browsers for
<video>
and<audio>
controls. For example theautostart
control may require different markup required in different browsers. - You should use a
<title>
attribute to aid assistive technologies such as screen readers.
Specification
Browser Support
Desktop
Chrome | Edge | Firefox | IE | Opera | Safari |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |