Copied successfully!
Introduction to <embed>
tag
The <embed>tag in HTML is used to embed external content, such as <multimedia files>
, documents, or interactive content, directly into a webpage. This tag is versatile and can handle a wide range of content types, including <Videos>
, <audio files>
, <PDFs>
, and even Flash applications. Understanding the use and attributes of the <embed>tag is essential for web developers looking to enhance the interactivity and multimedia experience of their websites.
Key Features of the <embed>
Tag
Embedding External Content: The <embed>tag is used to embed external resources into a webpage, such as videos, audio clips, interactive maps, games, and documents like PDFs or Microsoft Office files.
Self-Closing Tag: The <embed>tag is a self-closing tag, meaning it does not require a closing tag. The embedded content or media is specified using attributes within the <embed>tag itself.
Supports Various Formats: The <embed>tag is highly flexible and supports a wide range of formats, including:
- Video formats such as
<MP4>
,<WebM>
, and<oGG>
- Audio formats such as
<MP3>
and<WAV>
- Document formats such as
<PDF>
- SWF for Flash content
(although Flash is deprecated and not recommended for use)
Copy to clipboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>title of <embed> tag</title>
</head>
<body>
<header>
<h1>Embedded PDF Example</h1>
</header>
<div class="container">
<h2>Embedded PDF Document</h2>
<p>Below is an example of an embedded PDF document using the <code><embed></code> tag:</p>
<div class="embed-container">
<embed src="books.pdf" type="application/pdf">
</div>
</div>
</body>
</html>
Copy to clipboard
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f6f9;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
flex-direction: column;
}
header {
background-color: #343a40;
color: #ffffff;
text-align: center;
padding: 20px;
width: 100%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: fixed;
top: 0;
left: 0;
z-index: 1000;
}
.container {
padding: 20px;
max-width: 900px;
width: 100%;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-top: 80px; /* Offset for fixed header */
}
h1 {
font-size: 2.5rem;
margin: 0;
font-weight: 600;
}
h2 {
font-size: 1.75rem;
color: #007bff;
margin-bottom: 20px;
border-bottom: 2px solid #e9ecef;
padding-bottom: 10px;
}
p {
line-height: 1.8;
margin: 0 0 20px;
font-size: 1.1rem;
color: #495057;
}
.embed-container {
position: relative;
width: 100%;
height: 600px; /* Adjust the height as needed */
background: #f4f6f9;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.embed-container embed {
border: none;
width: 100%;
height: 100%;
}
Global Attributes
Attributes | Description |
---|---|
accesskey | Specifies a shortcut key to activate or focus an element. |
autocapitalize | Controls whether and how text input is automatically capitalized. |
class | Specifies one or more class names for the element, allowing CSS styling and JavaScript manipulation. |
contenteditable | Specifies whether the content of an element is editable or not. |
contextmenu | Specifies a context menu for the element. |
dir | Defines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto". |
draggable | Specifies whether an element is draggable. Possible values are "true" or "false". |
enterkeyhint | Specifies the action label or icon to be shown for the enter key on virtual keyboards. |
hidden | Indicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set. |
id | Specifies a unique identifier for the element. |
inputmode | Provides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants. |
is | Allows you to specify the type of custom element. |
lang | Specifies the language of the element's content. |
nonce | A cryptographic nonce ("number used once") that can be used by Content Security Policy (CSP) to determine whether or not a given fetch will be allowed to proceed. |
part | Specifies the element’s part in the shadow DOM. |
slot | Assigns a slot in a shadow DOM shadow tree. |
spellcheck | Indicates whether the element is subject to spell checking. |
style | Provides inline CSS styling for the element. |
tabindex | Specifies the tab order of the element. |
title | Adds extra information about the element, displayed as a tooltip when hovering over the element. |
translate | Specifies whether the content of the element should be translated. Possible values are "yes" or "no". |
HTML Attributes | Global Attributes | Event Attributes |
---|---|---|
To view the full list | To view the full list | To view the full list |
elements | |||||
---|---|---|---|---|---|
<embed> | Yes | Yes | Yes | Yes | Yes |
Improve Our Platform
Did you find what you were looking for?
Learn how to contribute.Last updated on by our contributors.
View this page on GitHub• Report an issue with this content