Description
The HTML element <embed>
is used to define a container for an external resource, which can be a web page, picture, media player, or plug-in application.
However, we have better options to include most of these resource types as mentioned below.
- Plug-ins are no more supported by modern browsers
- It's suggested to use the
<img>
element to include a picture - It's suggested to use the
<iframe>
element to include a web page - It's better to use the
<audio>
element to include audio into a web page - It's better to use the
<video>
element to include video into a web page
So, use the <embed>
element only if you don't find a specific element for the resource type you need to embed into a web page.
The below table summarizes its usage.
Usage Details | |
Placement | It is displayed as a Block element. |
Contents | None. It is an empty element. |
Tags | Only an opening tag is required. |
Versions | HTML5 |
Syntax
Here is the basic syntax of the <embed>
element.
<embed>
Examples
In the below example, the <embed>
element is used to include a picture, a web page, and a video.
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>HTML Element - embed</h1>
<embed type="image/jpg" src="picture.jpg" width="400" height="300">
<embed type="text/html" src="home.html" width="500" height="400">
<embed type="video/webm" src="video.mp4" width="300" height="200">
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <embed>
tag.
Attribute Type | Details |
Element-Specific Attributes | The tag <embed> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <embed> supports the HTML Global Attributes. |
Event Attributes | The tag <embed> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <dialog>
element.
Attribute | Value | Description |
width | number (in pixels) | Specifies the width of the embedded content in pixels |
height | number (in pixels) | Specifies the height of the embedded content in pixels |
src | URL | Specifies the URL of the resource embedded. |
type | content-type | Specifies the type of the resource embedded. |
Browser Compatibility
The tag <embed>
is supported in all modern browsers.
- Google Chrome 2+
- Internet Explorer or Edge 5.5+
- Firefox 1+
- Apple Safari 1.3+
- Opera 9.2+