CSS backgrounds are appropriate for decoration and layered presentation, but they do not carry img semantics and can be discovered later than HTML images. A meaningful image usually belongs in an img or picture element. If a decorative background becomes the Largest Contentful Paint resource, delivery and preload decisions need measured attention.
Use CSS backgrounds only where semantics permit, and prevent a critical background from being discovered too late.
Repeatable method
1. Classify the image
Ask whether losing the image would remove information. If yes, use semantic HTML instead of background-image.
2. Create layout-specific assets
Use media queries or image-set for real changes in resolution. Keep the fallback valid and avoid downloading hidden desktop and mobile assets together.
3. Inspect discovery timing
Record when the CSS file and background request appear in Network. Compare against an img implementation on a controlled page.
4. Preload only proven critical assets
If the background is consistently LCP and delayed, test an image preload with a matching type and URL. Remove experiments that do not improve the trace.
<link rel="preload" as="image" href="hero.webp" type="image/webp" fetchpriority="high">
Controlled background-discovery fixture
Create two otherwise identical test pages using the same 1600 × 900 illustrative asset URL. Variant A applies it through CSS; Variant B uses a semantic image. These are test inputs, not reported performance results.
.hero-a { background-image: url("/fixtures/hero-1600.webp"); background-size: cover; }
<img class="hero-b" src="/fixtures/hero-1600.webp" width="1600" height="900" alt="[describe only if meaningful]">
Serve both pages with the same stylesheet, markup above the hero, cache state, viewport, and network profile. In DevTools, preserve the Network log and capture the stylesheet request, image request, request initiator, priority, and LCP element. Then test one additional Variant A containing a matching preload for the exact URL. Record values in a table with columns for variant, CSS discovery time, image request start, priority, LCP resource, duplicate request count, and notes. Do not keep the preload merely because it starts the request earlier; retain it only after repeated traces show that it addresses the documented delay without fetching an unused breakpoint asset.
What to record
Record semantic classification, CSS selector, stylesheet discovery time, image request start, LCP element, preload markup, viewport, network profile, cache state, and before/after traces.
A result belongs to the source file, encoder, settings, browser, viewport, cache state, and date that produced it. Repeat the test on representative files before changing a production workflow.
Common mistakes
- Using backgrounds for informative charts or product images
- Preloading every decorative background
- Downloading both mobile and desktop variants
- Claiming an LCP improvement from one noisy run
Verification checklist
Run several cold-cache tests, inspect the LCP element, verify only the matching asset downloads, and disable the background to confirm the page retains its meaning. Recheck real-user data before treating a lab improvement as production success.
Primary references
Related lab notes
About this guide
We distinguish documented platform behavior from our workflow recommendations. See the testing methodology, editorial policy, and corrections log.