Document.embeds is a read-only instance property that returns a live HTMLCollection of every <embed> element in the document. Learn how to count, loop, read src, compare plugins and querySelectorAll, and use five examples with try-it labs.
01
Kind
Read-only property
02
Returns
HTMLCollection
03
Matches
<embed> only
04
Live
Updates with DOM
05
Alias
document.plugins
06
Status
Baseline widely
Fundamentals
Introduction
The HTML <embed> element inserts external content into a page—historically plugin formats, today often PDFs or other browser-handled resources. When a script needs every embed on the page, document.embeds gives a ready-made collection.
MDN: the embeds read-only property returns a list of the embedded <embed> elements within the current document. The HTML standard roots that collection at the document and filters only embed elements.
💡
Not every “embedded” tag
iframe, object, video, and audio are separate elements. They do not appear in document.embeds. Query those tags explicitly when needed.
A read-only instance property on Document. Its value is a live HTMLCollection of every <embed> in the document tree.
Value — HTMLCollection of embed elements (MDN).
Read-only — you do not assign a new collection to document.embeds.
Live collection — reflects DOM changes when embeds are added or removed.
Indexed access — document.embeds[i] or item(i).
Named access — embeds with a name / id may be reachable via namedItem.
Same as plugins — document.plugins returns the same collection in modern HTML.
Foundation
📝 Syntax
JavaScript
document.embeds
Value
An HTMLCollection of <embed> elements in the document.
Common patterns
JavaScript
const count = document.embeds.length;
const first = document.embeds[0];
const byName = document.embeds.namedItem("reportPdf");
for (const el of document.embeds) {
console.log(el.src);
}
CSS-selector alternative
JavaScript
const embeds = document.querySelectorAll("embed");
// Static NodeList — does not auto-update when you add/remove embeds
Compare
⚖️ document.embeds vs Related APIs
API
Returns
Notes
document.embeds
Live HTMLCollection of embed
Baseline Document property (MDN)
document.plugins
Same collection as embeds
HTML alias for embed elements
document.querySelectorAll("embed")
Static NodeList
Flexible CSS filters
document.getElementsByTagName("embed")
Live HTMLCollection
Similar live behavior
document.querySelectorAll("iframe")
iframe nodes
Not part of embeds
HTML
📄 Quick look at <embed>
An embed points at a resource with src and often a type MIME hint. Dimensions use width / height.
For video/audio use <video> / <audio>. For nested browsing contexts use <iframe>. Keep <embed> for cases where that element is the right fit (for example some PDF viewers).
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
All embeds
document.embeds
Count
document.embeds.length
First embed
document.embeds[0]
Read source
document.embeds[0].src
Same collection
document.plugins
Static NodeList
document.querySelectorAll("embed")
MDN status
Baseline Widely available
Snapshot
🔍 At a Glance
Four facts about document.embeds.
Type
HTMLCollection
Read-only, live
Contains
embed
Only that tag
Alias
plugins
Same list
Status
baseline
Standard API
Compare
📋 What appears in document.embeds?
Markup
In document.embeds?
How to select instead
<embed src="a.pdf">
Yes
document.embeds or querySelectorAll("embed")
<iframe src="page.html">
No
querySelectorAll("iframe")
<object data="a.pdf">
No
querySelectorAll("object")
<video src="clip.mp4">
No
querySelectorAll("video")
<img src="pic.png">
No
document.images / querySelectorAll("img")
Hands-On
Examples Gallery
Examples follow MDN Document: embeds. Use View Output or Try It Yourself for each case.
📚 Getting Started
Count embeds and read each resource URL.
Example 1 — Check document.embeds.length
Count how many <embed> elements exist on the page.
JavaScript
const count = document.embeds.length;
console.log("embed count:", count);
if (count === 0) {
console.log("No <embed> elements on this page");
}
length only counts <embed> tags—not iframes or objects.
Example 2 — Loop and List Each src
Walk the live collection and log each embed’s source.
JavaScript
for (const el of document.embeds) {
console.log(el.tagName, el.src || "(no src)");
}
// Classic index loop also works:
for (let i = 0; i < document.embeds.length; i++) {
console.log(i, document.embeds[i].src);
}
Document.embeds is marked Baseline Widely available on MDN (since June 2018). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Document.embeds
Read-only live HTMLCollection of every <embed> element in the document.
WidelyAvailable
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerSupported in legacy IE
Full support
Document.embedsBaseline support
Bottom line: Use document.embeds to list every embed on a page. Remember it excludes iframe/object/video — and that document.plugins points at the same collection.
Wrap Up
Conclusion
Document.embeds is the standard, live list of every <embed> in a document. Use it to count, inspect src, and keep scripts in sync with DOM changes—and remember that iframes and objects live in other queries.
Prefer video / audio / iframe when they fit better
Use querySelectorAll for filtered selectors
Treat plugins and embeds as the same list today
❌ Don’t
Expect iframes or objects inside document.embeds
Assume a missing src still loads content
Confuse live HTMLCollection with static NodeList
Assign to document.embeds (it is read-only)
Rely on old NPAPI plugin APIs—those are gone
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.embeds
Live HTMLCollection of every <embed> — Baseline and ready to use.
5
Core concepts
📄01
Returns
HTMLCollection
API
✓02
Status
baseline
Standard
📦03
Matches
<embed>
Only
🔄04
Live
auto-updates
DOM
🔗05
Alias
plugins
Same list
❓ Frequently Asked Questions
A read-only HTMLCollection of every <embed> element in the current document. MDN describes it as the list of embedded elements within the document.
No. MDN marks Document.embeds as Baseline Widely available (since June 2018). It is a standard Document collection property.
No. The HTML standard filters only embed elements. Use document.querySelectorAll("iframe") or "object" for those other embedding tags.
Yes in modern HTML: document.plugins returns the same HTMLCollection as document.embeds (the embed elements in the document).
Yes. HTMLCollection is live — if you add or remove an <embed>, document.embeds.length and indexed access update automatically.
Both work. document.embeds is a convenient live collection of all embeds. querySelectorAll("embed") returns a static NodeList and supports richer CSS selectors when you need filters.
Did you know?
In the HTML living standard, document.plugins is defined to return the sameHTMLCollection as document.embeds. The “plugins” name is historical; today it simply means the embed elements in the document.