Embed

Struct Embed 

Source
pub struct Embed;
Expand description

The <embed> element - embeds external content at the specified point.

§Purpose

The <embed> element represents an integration point for external application or interactive content, typically handled by a browser plugin. While historically used for Flash and other plugins, it’s now primarily used for embedding PDFs and other plugin-based content. Modern alternatives like <video>, <audio>, and <iframe> are preferred when applicable.

§Content Categories

  • Flow Content
  • Phrasing Content
  • Embedded Content
  • Interactive Content
  • Palpable Content

§Permitted Content Model

  • None (void element)

§Common Use Cases

  • Embedding PDF documents inline
  • Displaying plugin-based content (legacy)
  • Embedding specialized media types
  • Integration with native applications
  • Displaying Flash content (legacy, deprecated)

§Key Attributes

  • src: URL of the resource to embed (required)
  • type: MIME type of the embedded content
  • width: Width in CSS pixels
  • height: Height in CSS pixels
  • Any custom attributes for the plugin

§Example

<!-- Embedding a PDF document -->
<embed src="/documents/manual.pdf"
       type="application/pdf"
       width="800"
       height="600">

<!-- Embedding with explicit dimensions -->
<embed src="/media/content.swf"
       type="application/x-shockwave-flash"
       width="640"
       height="480">

<!-- Simple embed without type -->
<embed src="/files/document.pdf" width="100%" height="500">

<!-- Embed with custom parameters -->
<embed src="/plugin/app.plugin"
       type="application/x-custom-plugin"
       width="400"
       height="300"
       quality="high">

§Accessibility

  • Provide alternative content mechanisms when possible
  • Ensure embedded content is keyboard accessible
  • Consider using modern alternatives (<iframe>, <video>, <audio>)
  • Test with assistive technologies
  • Provide download links as fallback

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Embed

Source§

const TAG: &'static str = "embed"

The HTML tag name (e.g., “div”, “span”, “img”).
Source§

const VOID: bool = true

Whether this is a void element (self-closing, no children allowed).
Source§

impl EmbeddedContent for Embed

Source§

impl FlowContent for Embed

Source§

impl InteractiveContent for Embed

Source§

impl PalpableContent for Embed

Source§

impl PhrasingContent for Embed

Auto Trait Implementations§

§

impl Freeze for Embed

§

impl RefUnwindSafe for Embed

§

impl Send for Embed

§

impl Sync for Embed

§

impl Unpin for Embed

§

impl UnwindSafe for Embed

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.