The <embed> Element
As defined in the HTML Living Standard, the <embed> element provides an integration point for an external resource, typically a non-HTML resource such as a media player or an interactive application.
<embed src="interactive-app.swf" type="application/x-shockwave-flash">
View HTML Living Standard: The embed element
Technical Requirements
- The
srcAttribute: Specifies the address of the resource being embedded. - The
typeAttribute: Gives the MIME type of the plugin to be used to render the resource. - Dimensions: The
widthandheightattributes give the dimensions of the embedded content in CSS pixels.
WCAG Requirement: Name, Role, Value
Success Criterion 4.1.2 (Level A): For all user interface components, the name and role can be programmatically determined.
Unlike <iframe>, the <embed> tag does not have a title attribute that is reliably used as an accessible name by all screen readers. To ensure compliance, wrap the <embed> in a container and use aria-label or aria-labelledby to describe the content.
Accessibility Warning: The Lack of Fallback
The <embed> element is a void element, meaning it does not have a closing tag and cannot contain fallback text content.
A11y Comparison: Use Object Instead?
Because <embed> offers no native way to provide an alternative for users whose browsers or assistive technologies cannot render the plugin, it is often safer to use the <object> element or more specific media tags like <video> or <audio>.
<!-- Better Alternative with Fallback -->
<object data="app.pdf" type="application/pdf">
<p>Your browser cannot display this PDF. <a href="app.pdf">Download it here.</a></p>
</object>
Best Practices
- Avoid Legacy Plugins: Most modern browsers have deprecated support for plugins like Flash. Only use
<embed>for resources that have native browser support (like SVGs or specific PDF implementations). - Keyboard Focus: Many embedded resources do not correctly manage keyboard focus, creating "keyboard traps." Always verify that a user can move focus in and out of the embedded content using only the Tab key.