← Chrome 158 reference · All APIs

v158 · css & svg · enabled by default

object-fit and object-position apply to SVG documents in <object> and <embed>

Same-origin SVG documents loaded through HTML <object> or <embed> elements are sized and positioned inside the element’s content box according to CSS object-fit and object-position, matching replaced-element behavior for <img> and aligning with Firefox. Previously, Chrome ignored both properties on embedded SVG documents and stretched the SVG viewport to the entire content box.

Limited availability (SVG in <object>/<embed>) — base object-fit & object-position are Baseline Widely available

  • Chrome · 158 (desktop, Android, WebView; same-origin only)
  • Edge · Chromium-based (follows Chrome 158; no BCD subfeature)
  • Firefox · Shipped (passes css-images SVG <object>/<embed> WPT suite)
  • Safari · Not yet shipped (WebKit Bug 317804)

The base object-fit and object-position web features are Baseline Widely available since 2022-07-15 per webstatus.dev, but neither BCD css/properties/object-fit.json nor object-position.json tracks a subfeature for SVG documents in <object>/<embed> (checked 2026-11-24). Because Safari does not apply object-fit/object-position to embedded SVG documents yet (WebKit Bug 317804), this specific capability is Limited availability.

at a glance

Shipped inChrome 158 (desktop, Android, Android WebView) — filed under “Enabled by default” in the milestone=158 listing (feature type: “Chromium catches up” in ChromeStatus API record)
Runtime flagSVGEmbeddedAsReplacedElement — implemented behind this flag since Chrome 141 and shipped by default in Chrome 158 per ChromeStatus (note: Blink’s runtime_enabled_features.json5 on main still listed status: "experimental" when checked 2026-11-24; flag can be tested via --enable-blink-features=SVGEmbeddedAsReplacedElement on earlier builds)
SpecificationHTML Living Standard §15.4.1 Embedded content; CSS Images 3 §4.5 object-fit & §4.6 object-position; Fullscreen API UA stylesheet
Tracking bugissues.chromium.org/41302806
Web platform tests60 SVG fit/position tests across object-fit-{fill,contain,cover,none,scale-down}-svg-001..006{o,e}.html, object-fit-dyn-aspect-ratio-001/002.html, and fullscreen/rendering/backdrop-object.html
ChromeStatus4886345347629056 — object-fit and object-position apply to SVG documents in <object> and <embed>

why it exists

The HTML rendering specification defines both <embed> and an <object> representing an image, plugin, or content navigable as replaced elements, and CSS Images 3 specifies that object-fit and object-position apply to all replaced elements. Previously, Blink applied replaced-element content-rect sizing to <img> and <video> but skipped it in LayoutEmbeddedObject for embedded SVG documents, forcing the SVG viewport to fill the entire content box regardless of author styles or the Fullscreen UA stylesheet’s object-fit: contain rule. Chrome 158 routes same-origin embedded SVG documents in <object> and <embed> through replaced-element sizing, matching Firefox and eliminating layout surprises when swapping between <img src="*.svg"> and interactive <object data="*.svg">.

Source: ChromeStatus motivation (4886345347629056); Blink layout_embedded_object.cc.

Syntax

No new CSS property or HTML attribute syntax is introduced; existing CSS Images 3 properties now govern the replaced content rectangle of same-origin SVG documents hosted in <object> and <embed>:

/* CSS Images Module Level 3 — §4.5 and §4.6 */
object-fit: fill | contain | cover | none | scale-down;   /* Initial: fill */
object-position: <position>;                               /* Initial: 50% 50% */

/* Target HTML elements hosting an SVG document */
object[type="image/svg+xml"],
embed[type="image/svg+xml"] {
  object-fit: contain;
  object-position: top right;
}

“The embed, iframe, and video elements are expected to be treated as replaced elements. … An object element that represents an image, plugin, or its content navigable is expected to be treated as a replaced element.”

This reference covers four parts of the Chrome 158 contract: object-fit sizing and SVG intrinsic dimensions, object-position placement and hit testing, dynamic updates, viewBox mutations, and Fullscreen UA styles, and element scope (<object>/<embed> vs <iframe>) and out-of-process frame limitations.

Source: HTML Living Standard §15.4.1 (normative quote fetched 2026-11-24); CSS Images 3 §4.5 & §4.6.

object-fit — sizing SVG documents with intrinsic dimensions and preserveAspectRatio

Inputs. All five CSS Images 3 object-fit keywords (fill, contain, cover, none, scale-down; initial value fill) apply to the concrete object size of the embedded SVG document’s viewport inside the <object> or <embed> content box. The concrete object size depends on the root <svg> element’s intrinsic dimensions (width/height attributes) and intrinsic aspect ratio (viewBox), and then the SVG’s own preserveAspectRatio maps the viewBox into that viewport:

Interaction of object-fit with root <svg> sizing attributes (verified from WPT object-fit-*-svg-001..006{o,e}.html)
Root <svg> attributesIntrinsic size / ratioEffect of object-fit
Explicit width, height, viewBox, and preserveAspectRatio="none" (e.g. colors-16x8.svg)Intrinsic size + ratio; stretches like a raster imagefill stretches to the content box; contain/cover preserve the intrinsic ratio; none renders at intrinsic size; scale-down chooses the smaller of none and contain
viewBox only, no width/height (e.g. colors-16x8-noSize.svg)Intrinsic aspect ratio only (no intrinsic width/height)contain and cover size the SVG viewport using the viewBox aspect ratio; none and fill fall back to the content box when no natural dimensions exist
Explicit width, height, viewBox, and default preserveAspectRatio (xMidYMid meet, e.g. colors-16x8-parDefault.svg)Intrinsic size + ratio; SVG itself preserves aspect ratio inside its viewportobject-fit sizes the SVG viewport (e.g. fill gives the SVG the full content box, while cover or none lets the viewport overflow and be clipped); inside that viewport, xMidYMid meet still scales the viewBox proportionally without distortion

Outputs. Blink computes the replaced content rectangle in LayoutEmbeddedObject::ReplacedContentRectFrom() using pixel-snapped replaced sizing (PreSnappedRectForPersistentSizing(LayoutReplaced::ReplacedContentRectFrom(base_content_rect))). With the initial values (object-fit: fill; object-position: 50% 50%), the replaced content rect equals the full content box, preserving backwards compatibility for unstyled embeds.

Source: WPT object-fit-contain-svg-001o.html (and support SVGs colors-16x8.svg, colors-16x8-noSize.svg, colors-16x8-parDefault.svg); Blink layout_embedded_object.cc.

object-position — alignment, clipping, and hit testing

Inputs. Any valid CSS <position> value (1- to 4-value keywords, lengths, and percentages; initial value 50% 50%), such as top right, bottom 1px right 2px, or top 25% left 25%.

Outputs. Positions the computed SVG concrete object rectangle within the <object> or <embed> content box, clipping any overflow at the content box edge (for example under object-fit: cover or none). In Blink’s LayoutEmbeddedContent::NodeAtPoint(), pointer hit testing checks ReplacedContentRect().Contains(result.LocalPoint()) and offsets child frame coordinates by ReplacedContentRect().offset, so interactive links and event handlers inside the embedded SVG match the visually positioned viewport rather than the unshifted content box.

Source: CSS Images 3 §4.6 object-position; Blink layout_embedded_content.cc; WPT object-fit-contain-svg-001o.html.

Dynamic mutations, viewBox changes, and Fullscreen UA stylesheet

Dynamic CSS updates. In Blink’s LayoutEmbeddedObject::StyleDidChange(), modifying object-fit or object-position on an <object> or <embed> immediately marks frame geometries dirty (SetNeedsUpdateGeometries()) and updates child paint properties (SetNeedsPaintPropertyUpdate()), resizing and repositioning the embedded SVG frame on the next paint.

Dynamic SVG viewBox / aspect-ratio changes. When script mutates the embedded SVG’s root attributes via objectEl.contentDocument.documentElement.setAttribute("viewBox", ...) (as verified in WPT object-fit-dyn-aspect-ratio-001.html), the changed intrinsic aspect ratio recalculates the object-fit / object-position replaced rectangle automatically.

Fullscreen rendering change. Because the Fullscreen API UA stylesheet applies object-fit: contain (intentionally non-!important) to :fullscreen elements, calling requestFullscreen() on an <object> or <embed> hosting an SVG document now letterboxes the SVG within the fullscreen viewport (exposing ::backdrop behind it) instead of stretching it to fill the screen. Authors who want stretched fullscreen behavior can override the UA rule with object:fullscreen { object-fit: fill; }.

Source: Blink layout_embedded_object.cc; WPT object-fit-dyn-aspect-ratio-001.html; WPT fullscreen/rendering/backdrop-object.html; Fullscreen API UA stylesheet.

Element scope, <iframe> exclusion, and out-of-process frame limitation

Element scope and context. This change applies specifically to <object> and <embed> elements whose loaded document is an SVG document (contentDocument().IsSVGDocument()). It requires no secure context, no permission, and no user activation (except requestFullscreen() for fullscreen mode).

Source: Blink layout_embedded_object.cc; ChromeStatus interop_compat_risks.

Errors, feature detection, and cross-browser fallbacks

Invalid object-fit or object-position values are silently dropped by the CSS parser (never throwing JS exceptions). Importantly, CSS.supports("object-fit", "contain") returns true in Chrome < 158 and Safari even though those browsers ignore object-fit on SVG documents inside <object> and <embed>:

Source: WebKit Bug 317804; ChromeStatus interop_compat_risks; BCD object-fit.json.

Examples

No interactive demo is published on the Chrome Platform Showcase for v158/object-fit-and-object-position-apply-to-svg-documents-in-object-and-embed/ yet (HEAD check returned 404 on 2026-11-24).

Sizing and positioning same-origin SVGs in <object> and <embed>

<figure class="svg-frame">
  <!-- Same-origin SVG document (LocalFrame) -->
  <object class="svg-contain" type="image/svg+xml" data="/assets/floorplan.svg"
          width="320" height="200">
    Fallback text if the SVG fails to load.
  </object>

  <embed class="svg-cover" type="image/svg+xml" src="/assets/floorplan.svg"
         width="320" height="200">
</figure>

<style>
  .svg-contain {
    width: 320px;
    height: 200px;
    border: 1px solid #999;
    object-fit: contain;
    object-position: top right;
  }

  .svg-cover {
    width: 320px;
    height: 200px;
    border: 1px solid #999;
    object-fit: cover;
    object-position: 25% 25%;
  }
</style>
Source: WPT object-fit-contain-svg-001o.html; CSS Images 3 §4.5 & §4.6.

Dynamic viewBox mutation and Fullscreen ::backdrop control

<style>
  .interactive-svg {
    width: 240px;
    height: 240px;
    object-fit: contain;
    object-position: 0 0;
  }

  /* Fullscreen UA stylesheet sets object-fit: contain automatically;
     style ::backdrop or override object-fit if desired. */
  .interactive-svg::backdrop {
    background: #111;
  }
</style>

<object id="chart" class="interactive-svg" type="image/svg+xml"
        data="/assets/chart.svg"></object>

<script>
  const obj = document.getElementById("chart");
  obj.addEventListener("load", () => {
    // Same-origin contentDocument: changing viewBox recalculates object-fit automatically
    const svgRoot = obj.contentDocument?.documentElement;
    if (svgRoot) {
      svgRoot.setAttribute("viewBox", "8 4 8 4");
    }
  });
</script>
Source: WPT object-fit-dyn-aspect-ratio-001.html; WPT fullscreen/rendering/backdrop-object.html.

Browser compatibility

Support for applying object-fit and object-position to SVG documents in <object> and <embed>. BCD has no dedicated subfeature for this case yet; per-browser status combines ChromeStatus, WebKit bug tracker, and WPT evidence (checked 2026-11-24). Base property versions are from BCD.
BrowserSVG in <object> / <embed>Evidence / notesBase object-fit / object-position (BCD)
Chrome (desktop, Android, WebView)158Enabled by default in Chrome 158 per ChromeStatus 4886345347629056 (previously behind SVGEmbeddedAsReplacedElement since M141). Same-origin (LocalFrame) SVG documents only; <iframe> unchanged32
EdgeUnknown
(Chromium 158)
Chromium-based; inherits Blink changes when SVGEmbeddedAsReplacedElement is enabled (note: wpt.fyi Edge 158.0.4370.33 showed Fail before the flag flipped to stable on main)79 (16–78 <img> only)
FirefoxShippedAlready applies object-fit and object-position to SVG in <object>/<embed> (exact initial release unrecorded in BCD; cited as Shipped/Shipping in ChromeStatus and authored the WPT css-images SVG suite)36
SafariNoNot yet implemented; tracked in WebKit Bug 317804 (status: NEW per ChromeStatus)10
Source: BCD object-fit.json; BCD object-position.json; ChromeStatus API record; WebKit Bug 317804; wpt.fyi.

Security and privacy

Applying object-fit and object-position to same-origin SVG documents in <object> and <embed> changes only CSS layout and paint geometry for already-accessible same-origin documents; cross-origin out-of-process frames (RemoteFrame) are explicitly excluded in Blink’s layout_embedded_object.cc, avoiding any cross-origin intrinsic-dimension disclosure across site-isolated processes. It introduces no new permissions, storage, network requests, or fingerprinting surface. Chromium’s ChromeStatus API record lists security and privacy reviews as Pending (checked 2026-11-24) with no reported security risks; CSS Images 3 Privacy & Security Considerations notes no new security issues for object sizing.

Source: Blink layout_embedded_object.cc; ChromeStatus 4886345347629056; CSS Images 3 Privacy & Security Considerations.

Specifications

see also