The <embed> tag in HTML is used to embed external content or media files (such as audio, video, or interactive elements like Flash) directly into a webpage.
- It is a self-closing tag
- It is often used for embedding files like PDFs, images, or other types of media that require a plugin or external application to display.
HTML
<!DOCTYPE html>
<html>
<head>
<title>embed Tag</title>
<style>
q {
color: #00cc00;
font-style: italic;
}
</style>
</head>
<body>
<p> <q>GeeksforGeeks</q> is loading.</p>
<br>
<embed src="loading2.swf"
type="application/x-shockwave-flash">
</body>
</html>
Syntax
<embed src="URL" type="MIME_type" width="width_value" height="height_value">
Attributes
Attribute Values
| Description
|
---|
height
| This attribute contains the attribute value in pixels. It is used to specify the height of the embedded content.
|
src
| It is used to hold the URL. It is used to specify the web address of the embedded content.
|
width
| The width value is set in pixels. It is used to specify the width of embedded content.
|
type
| It contains the media_type content. It is used to specify the media type of the embedded content.
|
embedded PDF and video using <embed> Tag
HTML
<!DOCTYPE html>
<html>
<body>
<h2>Embed a PDF Document</h2>
<embed src="example.pdf" type="application/pdf"
width="400" height="200" />
<h2>Embed a Video</h2>
<embed src="example.mp4" type="video/mp4"
width="400" height="200" />
</body>
</html>
HTML <embed> Tag – FAQs
What file formats can be embedded using the <embed> tag?
Common file formats embedded using the <embed> tag include media files like .mp4, .mp3, .wav, .pdf, and .swf (Flash). It can also embed other types of content depending on browser support and plugins.
How do I specify the size of the embedded content using the <embed> tag?
You can control the width and height of the embedded content using the width and height attributes. Example: <embed src=”example.pdf” width=”600″ height=”400″>.
Is the <embed> tag still relevant, or is it outdated?
The <embed> tag is still relevant in certain scenarios but is often replaced by more modern tags like <video>, <audio>, and <iframe>, which provide better control and compatibility for embedding media.
What is the difference between the <embed> and <iframe> tags?
The <embed> tag is primarily used for embedding interactive content like media files, while <iframe> is used to embed an entire web page or external content within your page, including HTML documents.
Is the <embed> tag self-closing?
Yes, the <embed> tag is self-closing in HTML5. It does not require a closing tag: <embed src=”file.pdf” width=”600″ height=”400″>.