Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use fit (usually CSS object-fit: contain) when every part of an image must remain visible. Use fill (usually object-fit: cover) when the image must occupy a fixed frame and controlled cropping is acceptable. Do not confuse that common “fill” meaning with CSS object-fit: fill, which can stretch an image and distort its proportions. The right choice depends on the platform’s definition, the image’s aspect ratio, and whether complete content or a full frame matters more.

The decision in one minute

Priority Choose Typical result
Show the entire source image Fit / contain Aspect ratio is preserved; empty bands may appear.
Keep a uniform card, tile or hero frame Fill / cover Aspect ratio is preserved; edges may be cropped.
Stretch content to exact dimensions CSS fill The image can be distorted when ratios differ.

“Fit” and “fill” are interface labels, not universal standards. CSS, SwiftUI and image-processing services use related words with different details. Always verify the option in the platform you are using.

How the aspect-ratio trade-off works

An image has a source aspect ratio (width divided by height), while its container has a box ratio. If those ratios differ, software has only a few honest choices:

  • Preserve the whole image and leave unused space.
  • Preserve the ratio and crop or clip part of the image.
  • Change the ratio by stretching the image.

Fit/contain chooses the first outcome. Fill/cover chooses the second. CSS fill chooses the third. A square container holding a wide photograph makes the difference obvious: contain produces top and bottom (or side) bands, cover removes some of the photograph’s sides, and fill makes people or objects look unnaturally wide or tall.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

CSS: contain, cover and fill

object-fit: contain (the usual fit behavior)

contain scales a replaced element such as <img> down or up so the complete intrinsic image fits inside the element’s content box while preserving its natural aspect ratio. If the box and image have different ratios, the remaining area is letterboxed or pillarboxed. The image is not cropped.

.product-image {
  width: 320px;
  height: 240px;
  object-fit: contain;
  background: #f2f2f2;
}

This is appropriate for logos, diagrams, screenshots, product photographs where the edges contain important information, and any image that must be inspected in full. The background color makes the unused area intentional rather than visually confusing.

object-fit: cover (the usual fill behavior)

cover preserves the image’s aspect ratio but scales it until the entire content box is covered. If the ratios differ, overflow is clipped. MDN describes the result this way: “If the object’s aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.”

.story-card img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

Use it for decorative thumbnails, avatar crops, catalog cards and hero imagery where a consistent rectangle is more important than every pixel of the source. Select source images with safe margins so cropping does not remove a face, label or product feature.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

object-fit: fill is a different operation

CSS fill sizes the replaced content to the content box without preserving the intrinsic aspect ratio. A 16:9 image placed in a 1:1 box is stretched into a square. It never crops, but geometric distortion can be severe. Use it only when distortion is intentional or the source is known to match the box ratio.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

The other CSS values

  • none leaves the content at its natural size; it can overflow or be clipped by the layout.
  • scale-down chooses whichever concrete size is smaller: the result of none or contain. It prevents enlargement while still allowing reduction.

These values apply to replaced content with a used width and height. Set both dimensions (or an aspect-ratio) when you need predictable behavior; an auto-sized dimension may leave the browser little opportunity to crop or letterbox.

Controlling a cover crop with object-position

object-position decides which part of an oversized image stays visible. The default is centered. Move the focal point toward the subject when a centered crop cuts it off.

.portrait img {
  width: 100%;
  height: 360px;
  object-fit: cover;
  object-position: 50% 20%; /* keep a face nearer the top */
}

.logo img {
  width: 180px;
  height: 80px;
  object-fit: contain;
  object-position: left center;
}

Test at every responsive width. A position that works in a desktop banner can remove important content on a narrow phone screen. If the subject location varies by image, store a focal-point value per asset or use contain instead.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Complete CSS examples for common layouts

Responsive product card

.card-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f7f7f7;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

The fixed aspect ratio gives cards a consistent height; overflow: hidden makes the cover crop explicit. Add an editorially chosen object-position for images with off-center subjects.

Complete screenshot or diagram

.diagram {
  width: min(100%, 900px);
  height: 500px;
  object-fit: contain;
  background: #111;
}

Contain keeps labels and edges visible. A dark background can reduce the distraction of side bands around a wide diagram.

Switching behavior at a breakpoint

.media img { object-fit: contain; }
@media (min-width: 768px) {
  .media img { object-fit: cover; }
}

Use this only when the design requirement really changes between phone and desktop. Verify that the desktop crop still preserves the subject; responsive CSS does not understand image semantics.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Accessibility and content safety

  • Keep meaningful words in HTML text or an accessible alt attribute; a crop can hide text embedded in an image.
  • Do not rely on a background band to communicate information. A user who cannot see the image still needs an equivalent description.
  • For logos and diagrams, contain is generally safer because cropping can remove identifying marks or relationships.
  • For cover thumbnails, provide a useful alt description of the subject, not “thumbnail.”
  • Check high-contrast and dark-mode backgrounds around contained images so edges remain visible.

Framework and image-service differences

SwiftUI

SwiftUI calls the choices ContentMode.fit and ContentMode.fill. Fit scales an image to fit along one axis and can leave empty space along the other. Fill occupies the view and may extend beyond its bounds; apply .clipped() when you need the excess hidden.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Image("diagram")
  .resizable()
  .aspectRatio(contentMode: .fit)

Image("hero")
  .resizable()
  .aspectRatio(contentMode: .fill)
  .frame(width: 320, height: 200)
  .clipped()

Tailwind CSS

Tailwind’s object-contain, object-cover and object-fill utilities map directly to the corresponding CSS declarations. Combine them with explicit width and height or an aspect-ratio utility. You can change from contain to cover at a responsive breakpoint, but the same cropping considerations apply.

Server-side transformations

Image transformation services may define options such as scale-down, contain and cover independently of browser layout. Read that service’s definition before assuming a parameter behaves like CSS. A server may also resize the pixels permanently, while CSS changes only presentation.

A practical selection checklist

  1. Identify whether any source pixel is essential. If yes, start with contain.
  2. Decide whether every card or viewport must have identical dimensions. If yes, start with cover.
  3. Compare source and container ratios at the narrowest and widest layouts.
  4. For cover, set object-position around the subject and test real content, not a placeholder.
  5. Use overflow: hidden or a framework clipping modifier when filled content must stay inside the frame.
  6. Reject CSS fill unless stretching is deliberate; it is not a synonym for cover.
  7. Check keyboard, screen-reader and text alternatives, especially where an image contains instructions or labels.

Performance, reliability and debugging

When an image looks distorted

Inspect the computed object-fit. If it is fill, change to contain or cover. Also check whether another rule changes width, height or a transform.

When the crop is wrong

Confirm that the element has a definite height or aspect ratio, then adjust object-position. If the subject cannot be kept visible across all breakpoints, use a different crop or contain for that asset.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

When empty bands appear unexpectedly

That is the expected contain result when ratios differ. Choose a background that fits the design, change the box ratio, or switch to cover only if losing edge content is acceptable.

When a framework option does not match CSS

Check the framework’s documentation and whether it clips overflow. “Fill” may mean content extends outside a view (SwiftUI) or that pixels are stretched (CSS). Name the platform in code comments and design specifications.

Loading cost

object-fit does not reduce the downloaded source file. Use appropriately sized, compressed responsive images separately; then use contain or cover to control their presentation. A high-resolution source cropped into a small card can still cost the same network and decode work as the uncropped source.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For automated website screenshots, ScreenshotNeo provides a single GET request and options for full-page capture, lazy-loaded images, CSS-selected elements, device and retina settings, dark mode, custom CSS or JavaScript, waits, request blocking, cookies, headers, geolocation, PDFs and more. It removes cookie/consent banners, newsletter popups and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the ScreenshotNeo documentation for authentication and all parameters. This runnable cURL example captures a WebP image:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 shots each month with no card. Paid plans start at $5 for 3,000 shots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000 and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan. Create a free ScreenshotNeo account to start without a card.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Frequently asked questions

Does contain change the image file itself?

No. CSS contain changes how the image is rendered inside its element; it does not edit or crop the source file.

Can cover improve privacy?

It can hide peripheral content visually, but it is not a reliable redaction method. Crop or remove sensitive pixels in an edited asset before publishing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I choose fit for every logo?

Usually, but confirm the logo’s required clear space and the container’s background. A fixed brand lockup may need a dedicated asset rather than an arbitrary crop.

Why does my image overflow when using fill?

In frameworks such as SwiftUI, fill can intentionally extend beyond the view. Clip the view when that overflow is not wanted; in CSS, check whether you selected object-fit: fill and whether the element itself has overflow rules.

Frequently Asked Questions

Does contain change the image file itself?

No. CSS contain changes presentation inside the element and does not edit or crop the source file.

Can cover be used as redaction?

No. A visual crop is not reliable redaction; remove sensitive pixels from the asset before publication.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why can fill overflow in a framework?

Some frameworks define fill as content extending beyond the view. Apply clipping when needed and verify the platform’s documented behavior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.