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)
Browser Compatibility: The <embed>tag is widely supported across all modern browsers, making it a reliable option for embedding multimedia content.

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

AttributesDescription
accesskeySpecifies a shortcut key to activate or focus an element.
autocapitalizeControls whether and how text input is automatically capitalized.
classSpecifies one or more class names for the element, allowing CSS styling and JavaScript manipulation.
contenteditableSpecifies whether the content of an element is editable or not.
contextmenuSpecifies a context menu for the element.
dirDefines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto".
draggableSpecifies whether an element is draggable. Possible values are "true" or "false".
enterkeyhintSpecifies the action label or icon to be shown for the enter key on virtual keyboards.
hiddenIndicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set.
idSpecifies a unique identifier for the element.
inputmodeProvides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants.
isAllows you to specify the type of custom element.
langSpecifies the language of the element's content.
nonceA 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.
partSpecifies the element’s part in the shadow DOM.
slotAssigns a slot in a shadow DOM shadow tree.
spellcheckIndicates whether the element is subject to spell checking.
styleProvides inline CSS styling for the element.
tabindexSpecifies the tab order of the element.
titleAdds extra information about the element, displayed as a tooltip when hovering over the element.
translateSpecifies whether the content of the element should be translated. Possible values are "yes" or "no".
HTML AttributesGlobal AttributesEvent Attributes
To view the full list
To view the full list
To view the full list
elementsChrome BrowsersMicrosoft Edge BrowserFirefox BrowsersSafari BrowserOpera Browser
<embed>YesYesYesYesYes