HTML embed Tag
HTML <embed>
tag can be used to include images, videos, another webpage, etc, into our webpage. The <embed>
tag creates a container, for which we can specify the width and height, and in that container, we can show anything we want, it can be an image, a video, another webpage by providing the URL for the resource.
The <embed>
tag is supported by internet explorer, Netscape Navigator, Windows as well as on Mac platforms.
It uses three mandatory attributes and these are: src
, height
, and width
.
HTML <embed>
Tag - Syntax and Usage
The <embed>
element is an open tag, which means it doesn't require a closing tag.
<embed src="URL_OF_RESOURCE" height="..." width="..." />
Here the src
attribute will provide the URL of the resource that we want to embed/include in our webpage.
HTML <embed>
Tag Basic Example
Let's take a simple example where we will use the embed tag to include a picture and a webpage:
In the example above, we have used the <embed>
tag to include an image by providing its URL and specifying the height
and width
attribute. In the width
attribute we provided the value auto, that is to automatically adjust the width as per the given height to maintain the aspect ratio. We can specify a value for width
attribute and provide the value as auto for height
attribute.
HTML <embed>
Tag Attributes
The <embed>
tag supports Global attributes and Event attributes, and has the following 4 specific attributes:
Attribute |
Description |
src |
specifies the URL of the resource to be embedded. This attribute is mandatory. |
width |
specifies the width of the embedded content |
height |
specifies the height of the embedded content |
type |
specifies the type of the embedded content |
Don't use <embed> Tag unnecessarily
We can use the <img> tag to include an image in a webpage, and use the <video> tag for adding a video in our webpage and to include any other webpage as snippet we can use the <iframe> tag. The <embed>
tag can be used for some specific usecase.
Browser Support for HTML <embed>
tag
Following browsers support this attribute:
-
Firefox 1+
-
Google Chrome 2+
-
Internet Explorer 5.5+
-
Safari 1.3+
-
Opera 9.2+