The CSS <object-fit> property allows us to control how an image or video fits into its container. This is especially important when the element’s size differs from its original aspect ratio.
The <object-fit> property sets how an image should fit into a box of defined width and height. The most common values are cover and contain.
The following examples show how the same image behaves with different object-fit values.
Cover fills the container by cropping the image, while contain keeps the entire image but may leave empty space in the container.
Object-fit is particularly useful for responsive design, but user experience should be considered.
Please sign in to ask Lara about CSS object-fit.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.