Blog · Transparent PNG · · 7 min read

Make Transparent PNGs Look Good on Dark and Light Sites

You remove the background from a photo, drop the transparent PNG onto your white web page, and it looks clean. Then a visitor switches their device to dark mode, or you place the same image on a dark banner, and suddenly there is a pale outline around the subject, a shadow that disappeared, or a white shirt that melts into the page. The cutout did not change. The background behind it did. This guide explains why transparent images behave differently on different backgrounds, how to test for problems in a couple of minutes, and how to fix or serve your files so they look right whether your site is light, dark, or somewhere in between.

Why a cutout can look perfect on white and wrong on dark

A transparent PNG is not just a subject with a hard edge. Along the outline, the pixels are usually partly transparent, so the edge blends smoothly into whatever sits behind it. Those partly transparent pixels still carry color, and that color often comes from the original photo's background. If your original photo was shot against a white wall or a bright sky, the edge pixels can hold a little of that brightness.

On a white page you never notice, because light fringe pixels blend into a light background. On a dark page, the same pixels glow as a thin pale line around the subject. It is the same issue behind the halos described in many cutout guides, but it only shows up once the background changes.

The reverse can happen too. A cutout made from a photo with a dark background can leave a faint dark edge that is invisible on a dark page but looks like a grimy outline on white. The lesson is simple: an edge that looks clean on one background has not been proven clean on all of them.

Test your cutout on four backgrounds before publishing

Before you upload anything, check the cutout against the backgrounds it might actually meet. You do not need special software. Any design tool, slide deck, or even a plain web page with a colored background will do.

Zoom in to at least 200 percent and look slowly at the edges, especially around hair, fur, fingers, and thin straps. Problems that are invisible at normal size often become obvious when you zoom, and visitors on high-resolution screens will see them.

Fix edge fringes at the source

If you see a pale or dark outline, the most reliable fix is to improve the cutout rather than hide the problem later. Start by checking the original photo. A subject shot against a background that is close in tone to where it will be used gives you cleaner edge pixels. If the cutout is headed for a dark page, a photo taken against a mid-tone or dark backdrop will usually produce a better result than one taken against bright white.

If you cannot reshoot, try running the removal again on the highest quality version of the photo you have. Heavily compressed or low-resolution images blur the boundary between subject and background, which creates more mixed-color edge pixels. A tool such as bgrm runs in your browser with no signup, so it is easy to try a second pass on a better source file and compare the edges side by side on your test backgrounds.

When a small fringe remains, you can often tidy it up by shrinking the mask by a pixel or two, or by softening the edge very slightly. Do this gently. Shrinking too far eats into the subject and makes it look cut out with scissors, which is a different kind of flaw. For hair and fur, accept a little softness rather than chasing a razor-sharp edge, since a hard edge on wispy detail looks less natural on any background.

Handle shadows and light-colored subjects deliberately

Two other things change when the background changes: shadows and subjects that match the page.

If your cutout includes a baked-in shadow, that shadow is stored as semi-transparent dark pixels. On a white page it looks natural. On a dark page it nearly vanishes, so your product appears to float with no grounding. A better approach for most web use is to export the subject without a shadow and add one with CSS, using the drop-shadow filter or a box-shadow on a wrapper. That way you can tune the shadow per theme, for example a softer, lower-opacity shadow on light pages and a subtler one on dark pages, where heavy black shadows rarely read well anyway.

The second problem is a subject whose own color matches the background. A white mug on a white page or a black jacket on a black page loses its outline. Solutions include placing the image on a subtly tinted panel or rounded card instead of directly on the page, adding a thin low-contrast outline or a soft glow, or choosing a background color for that section that contrasts with the subject. Often the simplest fix is a neutral card behind the image that stays the same in both themes.

Serve different versions for light and dark themes

Sometimes one file simply cannot suit both themes. This is common with logos, icons, and illustrations that contain dark text or thin dark lines. A black logo on a transparent background disappears on a dark page, and a white logo is invisible on a light one. For these, create two versions and name them clearly, such as logo-light-bg.png and logo-dark-bg.png.

You can then show the right one automatically. The HTML picture element lets you add a source with a media query for prefers-color-scheme: dark, with the standard image as the fallback. Alternatively, if your site toggles themes with a class, you can swap images with CSS by showing one and hiding the other. Either way, give both versions the same pixel dimensions so the layout does not jump when the theme changes, and keep the alt text identical.

For ordinary photo cutouts such as products or people, one file is usually enough if the edges are clean and you handle shadows in CSS. Maintaining two versions of every photo is extra work that rarely pays off, so save the dual-file approach for images where the subject colors truly clash with one of the themes.

Export settings and a few places that surprise people

Use a format that supports transparency. PNG and WebP both do, while JPG does not and will fill the transparent area with a solid color, usually white. If file size matters, WebP with transparency is a good option, but check that your platform accepts it before relying on it.

Export at the display size you need, plus extra resolution for high-density screens, rather than uploading a huge file and letting the browser shrink it. Scaling a transparent image down in the browser is fine, but an oversized file slows pages for no visual gain.

Also remember that your image may appear in places you do not control. Some email apps and messaging tools apply their own dark mode or place images on a colored bubble. Social platforms and marketplaces may flatten transparency onto white or black. If the image will travel beyond your own site, preview it in those places, and consider whether a flat background color baked into the file would be safer for that specific use.

Frequently asked questions

Why does my transparent PNG have a white outline only on dark backgrounds?

The semi-transparent pixels along the edge still carry some color from the original photo's background. When that background was light, those pixels look like a pale line against a dark page. Redoing the cutout from a cleaner, higher-resolution source, or slightly shrinking the edge, usually fixes it.

Do I need separate images for light mode and dark mode?

Usually not for photos. If the edges are clean and shadows are added with CSS, one cutout works on both. Separate versions are mainly useful for logos, icons, and line art where the subject color clashes with one of the backgrounds.

Should I bake a drop shadow into the PNG?

For web use it is generally better to leave it out and add the shadow with CSS. A baked-in shadow is semi-transparent black, which looks fine on white but almost disappears on dark backgrounds. CSS lets you adjust it for each theme.

Is WebP safe to use instead of PNG for transparent images?

WebP supports transparency and often produces smaller files, and modern browsers handle it well. Just confirm that every place you upload the image, such as a store platform or email tool, accepts WebP, and keep a PNG on hand as a fallback.

Conclusion

A transparent image is only as good as it looks on the background it lands on, and that background is not always the one you designed against. Test your cutouts on white, near black, gray, and your brand color, fix fringes at the source, move shadows into CSS, and use separate files only where a subject truly cannot work on both themes. A few minutes of checking before you publish saves you from the pale outlines and vanishing logos that make an otherwise polished page look careless.

Ready to make a clean cutout you can test on any background? Try bgrm, the free in-browser background remover with no signup, and preview your transparent PNG on light and dark backgrounds before you publish.

Remove a background free