KKitForma.

Language

EnglishEnglishTürkçeTurkishGuide unavailable in this language · open toolsDeutschGermanGuide unavailable in this language · open toolsEspañolSpanishGuide unavailable in this language · open toolsFrançaisFrenchGuide unavailable in this language · open toolsPortuguêsPortugueseGuide unavailable in this language · open toolsItalianoItalianGuide unavailable in this language · open toolsNederlandsDutchGuide unavailable in this language · open toolsPolskiPolishGuide unavailable in this language · open toolsРусскийRussianGuide unavailable in this language · open toolsУкраїнськаUkrainianGuide unavailable in this language · open toolsSvenskaSwedishGuide unavailable in this language · open toolsNorskNorwegianGuide unavailable in this language · open toolsDanskDanishGuide unavailable in this language · open toolsSuomiFinnishGuide unavailable in this language · open toolsČeštinaCzechGuide unavailable in this language · open toolsRomânăRomanianGuide unavailable in this language · open toolsΕλληνικάGreekGuide unavailable in this language · open toolsالعربيةArabicGuide unavailable in this language · open toolsעבריתHebrewGuide unavailable in this language · open toolsفارسیPersianGuide unavailable in this language · open toolsاردوUrduGuide unavailable in this language · open toolsहिन्दीHindiGuide unavailable in this language · open toolsবাংলাBengaliGuide unavailable in this language · open toolsதமிழ்TamilGuide unavailable in this language · open toolsతెలుగుTeluguGuide unavailable in this language · open toolsमराठीMarathiGuide unavailable in this language · open toolsગુજરાતીGujaratiGuide unavailable in this language · open tools简体中文Chinese SimplifiedGuide unavailable in this language · open tools繁體中文Chinese TraditionalGuide unavailable in this language · open tools日本語JapaneseGuide unavailable in this language · open tools한국어KoreanGuide unavailable in this language · open toolsTiếng ViệtVietnameseGuide unavailable in this language · open toolsไทยThaiGuide unavailable in this language · open toolsBahasa IndonesiaIndonesianGuide unavailable in this language · open toolsBahasa MelayuMalayGuide unavailable in this language · open toolsFilipinoFilipinoGuide unavailable in this language · open toolsKiswahiliSwahiliGuide unavailable in this language · open toolsAfrikaansAfrikaansGuide unavailable in this language · open toolsMagyarHungarianGuide unavailable in this language · open toolsБългарскиBulgarianGuide unavailable in this language · open toolsHrvatskiCroatianGuide unavailable in this language · open toolsSrpskiSerbianGuide unavailable in this language · open toolsSlovenčinaSlovakGuide unavailable in this language · open toolsSlovenščinaSlovenianGuide unavailable in this language · open toolsLietuviųLithuanianGuide unavailable in this language · open toolsLatviešuLatvianGuide unavailable in this language · open toolsEestiEstonianGuide unavailable in this language · open toolsCatalàCatalanGuide unavailable in this language · open toolsEuskaraBasqueGuide unavailable in this language · open tools
← Questions & answers

KITFORMA · EDITORIAL ANSWER

Why does object-fit:cover crop the subject of a product image?

KitForma editorial guide. Compare cover and contain using the same 2:1 image in square boxes, then choose whether cropping or letterboxing is acceptable.

HTML, CSS & accessibility →

Step-by-step answer

object-fit: cover fills the box by cropping when source and box ratios differ. contain keeps the full image visible and leaves space. Save this example as an HTML file to compare them. Runnable example:
html
<!doctype html>
<meta charset="utf-8">
<title>Cover versus contain</title>
<style>
img { width:200px; height:200px; background:#eee; border:1px solid; }
</style>
<p>Cover (cropped):</p>
<img alt="Wide image with marked ends" style="object-fit:cover"
  src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='200'%3E%3Crect width='400' height='200' fill='steelblue'/%3E%3Ccircle cx='20' cy='100' r='20' fill='gold'/%3E%3Ccircle cx='380' cy='100' r='20' fill='gold'/%3E%3C/svg%3E">
<p>Contain (complete):</p>
<img alt="Wide image with marked ends" style="object-fit:contain"
  src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='200'%3E%3Crect width='400' height='200' fill='steelblue'/%3E%3Ccircle cx='20' cy='100' r='20' fill='gold'/%3E%3Ccircle cx='380' cy='100' r='20' fill='gold'/%3E%3C/svg%3E">
Expected result: Cover shows a centered 200 × 200 portion of the 400 × 200 image, hiding both gold ends. Contain displays all 400 × 200 source pixels at 200 × 100, with 50 CSS pixels of space above and below. Why it works: Cover uses the larger scale needed to fill both dimensions; contain uses the smaller scale that fits both. object-position can move the crop toward a focal point, but cannot make all content fit while also filling a mismatched box. Scope and checks: CSS Images Level 3 in modern browsers. Measurements above describe the content box and exclude the 1-pixel border. The file remains unchanged. For product pages where labels or edges must remain visible, review portrait and landscape assets before choosing the display rule. Related tools and guides: Make an intentional file crop: https://kitforma.com/en/image-crop/ Reserve image space before loading: https://kitforma.com/en/community/questions/7aa10000-0000-4000-8000-000000003340/ Primary sources (reviewed 2026-10-08): W3C CSS Images Level 3 — object-fit: https://www.w3.org/TR/css-images-3/#the-object-fit

Sources and verification

Sources checked:

This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.

Discussion and community answers

Loading community…
KitForma

What would you like to do?