A PNG with a transparent background can look perfect on a white page and fail on a dark one: dark text disappears into the background, and a light halo appears around the image. MDN documents the prefers-color-scheme media feature, which lets a page detect a dark or light preference, and the color-scheme property, which opts a page into light, dark, or both. Check the transparent PNG on a dark background before it is used, because transparency alone does not make an image dark-mode safe.
What you need
- The AI-generated PNG with transparency
- A dark background to test it on
- A light background for comparison
Step 1: Place the PNG on a dark background
Put the transparent PNG on a dark background at the size it will be used, and look at the whole image. Note any part that disappears into the background or gains a halo.
Step 2: Compare it with the same PNG on a light background
Place the same PNG on a light background and compare. A part that is visible on light and invisible on dark is a dark-mode failure.
Step 3: Fix the image or provide a dark-mode version
If part of the image disappears on dark, lighten that part, add an outline, or provide a separate dark-mode version of the image. Re-check on both backgrounds after the fix.
Worked example: synthetic dark-mode check of one transparent PNG
The table below is a synthetic example. It shows the expected result of checking one transparent PNG logo; no logo was used.
| Logo part | On light | On dark | Verdict |
|---|---|---|---|
| Main mark | Visible | Visible | Pass |
| Wordmark text | Visible | Disappears | Fail |
| Accent line | Visible | Visible | Pass |
| Small icon | Visible | Faint halo | Fail |
Expected result (UNTESTED). the main mark and accent line pass on both backgrounds, and the wordmark disappears on dark while the small icon shows a halo, so the logo needs a dark-mode version before use. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A transparent PNG is not the same as a dark-mode PNG; check the image on a dark background, not only in a transparent viewer.
- A halo around a transparent image often comes from a white background that was not fully removed, so re-cut the edge.
- A separate dark-mode version of an image needs to be kept in step with the light version, so label both clearly.
- Operating system dark mode and site dark mode can differ, so check both where the site has its own toggle.
