Last updated: 8 February 2026

Tailwind CSS Object Fit

Control how images and videos fit their containers in Tailwind CSS with object-cover, object-contain, object-fill, and more. Essential for responsive media.


Interactive Object Fit Playground

Try each class live and inspect the CSS output.

Preview
Utility class
object-cover
CSS output
object-fit: cover;

The object-{fit} utility class in Tailwind CSS allows you to control how an image or video content fits within its container. With Tailwind's object-{fit} class, you can easily adjust the scaling and positioning of media elements to achieve the desired visual effect.

How to apply Tailwind Object Fit

To apply the object fit behavior to an element, you can use the object-{fit} utility class, where {fit} represents the desired fitting mode. The available fitting modes are:

  • object-contain: Scale the content proportionally to fit within the container while preserving its aspect ratio.
  • object-cover: Scale the content proportionally to completely cover the container, potentially cropping parts of the content.
  • object-fill: Stretch the content to fill the container, disregarding its aspect ratio and potentially distorting the content.
  • object-none: Display the content at its original size, ignoring the container's dimensions and aspect ratio.
  • object-scale-down: Scale the content down if it is larger than the container, maintaining its aspect ratio. Here's an example:
HTML
1<img src="image.jpg" class="object-cover" />

Responsive Object Fit

Tailwind CSS allows you to apply object fit classes responsively at different breakpoints. To use responsive object fit classes, you can append the breakpoint prefix to the utility class. For example, md:object-fill sets the object fit behavior to object-fill starting from the medium breakpoint and above.

HTML
1<img src="image.jpg" class="object-contain md:object-fill" />

In the above example, the object fit behavior of the <img> element is set to object-contain by default, but starting from the medium breakpoint and above, it changes to object-fill.

Tailwind Object Fit Class Table

ClassProperties
object-containobject-fit: contain;
object-coverobject-fit: cover;
object-fillobject-fit: fill;
object-noneobject-fit: none;
object-scale-downobject-fit: scale-down;

🔍 Want to Learn More?

Windframe Tailwind blocks

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates