Web design and digital-business ideas grounded in real tasks.

Using object-view-box to choose which part of an image is shown

A web designer examining several crops of the same original landscape photograph on a monitor, believable clean interface without readable text.
AI-generated photographic illustration; not documentary photography.

Sometimes a layout needs to emphasise one part of a photograph while keeping the original asset available. The CSS object-view-box property defines a view into the content of a replaced element such as an image. It can change the displayed section without editing the source file.

MDN’s property reference documents rectangular view-box functions and currently marks browser availability as limited. Treat it as an enhancement that needs testing, not a feature every visitor’s browser can be assumed to support.

A small experiment

Begin with an image that is already understandable when shown normally. Then apply a supported value inside a feature query:

.detail-photo {
  max-width: 100%;
  height: auto;
}
@supports
  (object-view-box:
    inset(20%)) {
  .detail-photo {
    object-view-box:
      inset(20%);
  }
}

This illustrative rule selects an inset region where the property is supported. The final appearance also depends on the image’s dimensions and the layout space. Test with the actual asset rather than expecting the same composition from unrelated photographs.

Check the page with the enhancement disabled. The fallback should still communicate the intended information. If a detail is essential to understanding a product or instruction, consider providing a dedicated detail image instead of making access depend on a CSS crop.

Review meaning as well as appearance

A crop can remove context. Confirm that it does not hide a relevant part of a diagram, change the apparent relationship between objects or leave the alternative text describing something no longer visible.

The original file is still delivered, so this is not a way to remove private information or reduce the image’s download size. Use a properly edited source for redaction and suitable image assets for performance. Keep the visual enhancement, accessibility and file preparation as separate decisions.