Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

embed

The embed element is a void element for embedding external content. It provides no fallback mechanism -- prefer modern alternatives like iframe, video, and audio.

Description

The <embed> element provides an integration point for external content or applications, typically handled by browser plugins. It is a void element (self-closing) with no closing tag and no fallback content mechanism.

Originally designed for plugin content like Flash and Java applets, <embed> has limited utility in modern web development. Unlike <object>, it cannot contain fallback markup, so if the resource fails to load the user sees nothing.

When to Use

In modern HTML, there is almost always a better alternative. The <embed> element should only be used when no other element supports the content type and you are certain the resource will load.

Prefer Modern Alternatives

  • Use <iframe> for embedding HTML documents and web applications
  • Use <video> for video content with native controls and captions
  • Use <audio> for audio content with native controls
  • Use <img> for images including external SVG files
  • Use <svg> for inline vector graphics
  • Use <object> if you need fallback content for a non-HTML resource

Examples

SVG File

PDF Document

width and height take integers (CSS pixels) only — width="100%" is invalid. Give integer fallback dimensions and let CSS make the box responsive.

Inline PDF rendering is a desktop-browser feature. Most mobile browsers do not render a PDF inside <embed>, and because <embed> has no fallback, those users see an empty box. For PDFs, prefer <object> with a download link inside it, and consider a visible download link next to the embed as well. Exact behaviour varies by browser and settings (some desktop users disable the built-in viewer), so test on your target devices.

Legacy Plugin Content

Plugin-based content (Flash, Java, Silverlight) is no longer supported by modern browsers. This syntax is shown for historical reference only.

embed vs. object

The key difference is fallback content. <embed> is a void element with no closing tag, so it cannot contain alternative markup. <object> supports content between its tags that is displayed when the resource fails to load.

For any use case where the resource might not load, prefer <object> or a native element over <embed>.

Sizing

VB styles <embed> and <object> as display: block with max-inline-size: 100%. On their own that clamps the width but not the height, because these elements have no natural aspect ratio — in a narrow container a 600×400 embed becomes a tall, letterboxed box. Two primitives fix that without inline styles:

  • data-ratio on the element — the block size follows the used width. A width attribute stays the preferred (maximum) width; without one the element fills its container. Values: 1:1, 4:3, 3:2, 16:9 (default), 21:9, 2:3, 3:4, 9:16, and page (1 : 1.414, a portrait document page). Also works on <iframe>.
  • data-media wrapper — a ratio box (data-ratio, data-radius) whose child <embed>, <object> or <iframe> fills it. The legacy .embed-responsive class works the same way. If the wrapper is a <figure> with a <figcaption>, the ratio applies to the media child and the caption flows below it (see figure).

When printing, VB keeps <embed> and <object> from splitting across pages and caps them at the page width.

Security

<embed> (like <object>) has no sandbox attribute. Embedded SVG and HTML documents run their scripts with the embedded document's origin, and same-origin content can reach into your page.

  • For untrusted or user-supplied SVG, use <img> — SVG loaded as an image never runs script.
  • For untrusted HTML, use <iframe sandbox>, which can strip script, forms and same-origin access.
  • The type attribute is only a hint. The server's Content-Type header decides how the resource is handled, so type="image/svg+xml" does not stop an HTML response from being rendered as HTML.
  • If you don't use these elements, turn them off with Content Security Policy: object-src 'none' blocks both <object> and <embed>.

Attributes

Attribute Description
src URL of the resource to embed.
type MIME type of the embedded content (e.g., image/svg+xml, application/pdf).
width Display width of the embedded content in pixels.
height Display height of the embedded content in pixels.

This element also supports global attributes.

Accessibility

The <embed> element has significant accessibility limitations:

  • No fallback content mechanism -- if the resource cannot be loaded, the user gets nothing
  • No native alt attribute like <img> — give every embed an accessible name with title or aria-label that describes the content (“2026 annual report (PDF)”), not the element (“Embedded content”)
  • Embedded content is opaque to screen readers unless the content itself is accessible
  • Prefer elements with built-in accessibility semantics (<img>, <video>, <audio>) whenever possible

Related

  • <object> - Similar embedding with fallback content support
  • <iframe> - For embedding HTML documents with security sandboxing
  • <video> - For video with native controls, captions, and multiple sources
  • <audio> - For audio with native controls and multiple sources
↑