object-fit and object-position apply to SVG documents in <object> and <embed>
- Category
- CSS
- Type
- Chromium catches up
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
WPT details: https://wpt.fyi/results/css/css-images/object-fit-contain-svg-001e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-001o.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-002e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-002o.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-003e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-003o.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-004e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-004o.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-005e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-005o.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-006e.html https://wpt.fyi/results/css/css-images/object-fit-contain-svg-006o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-001e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-001o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-002e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-002o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-003e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-003o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-004e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-004o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-005e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-005o.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-006e.html https://wpt.fyi/results/css/css-images/object-fit-cover-svg-006o.html https://wpt.fyi/results/css/css-images/object-fit-dyn-aspect-ratio-001.html https://wpt.fyi/results/css/css-images/object-fit-dyn-aspect-ratio-002.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-001e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-001o.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-002e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-002o.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-003e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-003o.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-004e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-004o.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-005e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-005o.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-006e.html https://wpt.fyi/results/css/css-images/object-fit-fill-svg-006o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-001e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-001o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-002e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-002o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-003e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-003o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-004e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-004o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-005e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-005o.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-006e.html https://wpt.fyi/results/css/css-images/object-fit-none-svg-006o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-001e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-001o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-002e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-002o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-003e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-003o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-004e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-004o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-005e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-005o.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-006e.html https://wpt.fyi/results/css/css-images/object-fit-scale-down-svg-006o.html
Summary
SVG documents loaded through <object> or <embed> are sized and positioned inside the element's content box according to the CSS object-fit and object-position properties, the same way <img> content is. Previously Chrome ignored both properties for embedded SVG documents and always stretched the document viewport to the whole content box.
Motivation
Authors use object-fit and object-position to control how replaced content is scaled and placed inside its box. https://drafts.csswg.org/css-images-3/#the-object-fit https://drafts.csswg.org/css-images-3/#the-object-position Currently, Chrome applies them to images and videos but ignores them for SVG documents loaded through <object> or <embed>, which are always stretched to fill the element. The fix has been implemented behind the SVGEmbeddedAsReplacedElement flag since M141. This entry ships it by default.
Standards & signals
- Specification: https://html.spec.whatwg.org/multipage/rendering.html#embedded-content-rendering-rules
- Firefox: Shipped/Shipping — See the related WPT tests in the css-images folders.
- Safari: No signal — Bug still in the NEW status.
- Web developers: No signals
- Tracking bug: https://issues.chromium.org/41302806
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=css%2Fcss-images%2Fobject-fit-contain-svg-001e
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+object-fit%20and%20object-position%20apply%20to%20SVG%20documents%20in%20%3Cobject%3E%20and%20%3Cembed%3E
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=object-fit%20and%20object-position%20apply%20to%20SVG%20documents%20in%20%3Cobject%3E%20and%20%3Cembed%3E
- Baseline status: https://webstatus.dev/?q=object-fit%20and%20object-position%20apply%20to%20SVG%20documents%20in%20%3Cobject%3E%20and%20%3Cembed%3E