property

Object view box — CSS reference

Changes the source region of a replaced object before fitting it into its box. In this two-color SVG image, the inset selects the left half; object-fit then scales that source into a square. The image element retains its reserved dimensions.

Formal Syntax & Structure

css syntaxcss
object-view-box: inset(0 50% 0 0);

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>object-view-box</title><style>body{margin:8px;font:16px/24px sans-serif}#a{width:100px;height:100px;object-fit:fill;object-view-box:inset(0 50% 0 0);display:block}</style><body><img id="a" alt="Red and blue color sample" src="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27200%27 height=%27100%27%3E%3Cpath fill=%27red%27 d=%27M0 0h100v100H0z%27/%3E%3Cpath fill=%27blue%27 d=%27M100 0h100v100H100z%27/%3E%3C/svg%3E"></body></html>
CSS Reference