Short answer: CSS does not provide the documented control for deferring an ordinary image request. Put loading='lazy' on the HTML <img>, then use CSS for responsive sizing and presentation. Keep above-the-fold and LCP images eager, and always provide dimensions so the browser can reserve their space.
Can you lazy-load an image with CSS alone?
Not for a normal <img>. CSS controls layout, sizing, visibility, and painting; the native browser hint for deferring an image fetch is the HTML loading attribute. The lazy value asks the browser to delay fetching until conditions associated with the element are met. The browser, not your stylesheet, chooses the distance from the viewport at which the request starts.
Use CSS to make the image fit its container, but keep the loading decision in HTML:
<img
src='gallery-image.jpg'
loading="eager"
width='1200'
height='800'
alt='A red kayak on a mountain lake'
>
img {
max-width: 100%;
height: auto;
}
loading='eager' is the default state. You can state it explicitly when an image must be requested immediately, but do not confuse eagerness with priority: loading='eager' does not itself raise network priority. fetchpriority is a separate hint for relative priority.
#1 Best Overall
What the browser does with loading='lazy'
Deferral distance is browser-controlled
There is no portable CSS value such as “start 500 pixels before the viewport.” User agents calculate their own fetch threshold from the element’s position and current conditions. Consequently, code should describe intent—noncritical, initially off-screen content—rather than promise an exact number of pixels or milliseconds.
Lazy does not mean “wait until the exact moment of paint”
The browser may begin downloading before an image is visible so it can be ready as the user scrolls. In Chrome-on-Android experiments reported by web.dev, 97.5% of lazy-loaded images were fully loaded within 10 ms of becoming visible on 4G, and 92.6% reached that mark on slow 2G. Those are observations from the cited experiments, not guarantees for every browser, connection, or current site.
Images above the fold are a different case
If an image is likely to appear in the initial viewport, especially the page’s Largest Contentful Paint (LCP) image, leave it eager. Deferring that request can make the most prominent content arrive later. Apply lazy loading to content that starts below the initial view or is otherwise noncritical.
Build a reliable HTML-and-CSS pattern
Reserve space with intrinsic dimensions
Include both width and height on each image. The browser can derive an aspect ratio from those values and reserve the box before downloading the file. That reduces layout shifts and also gives lazy-loading logic a concrete layout position. Lazy images without an established size can fail to load when they do not intersect a visible part of an element.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
<figure class='card-media'>
<img
src='photos/forest-trail.webp'
loading="eager"
width='1600'
height='1067'
alt='A shaded trail through a green forest'
>
<figcaption>North loop trail</figcaption>
</figure>
.card-media {
margin: 0;
aspect-ratio: 1600 / 1067;
overflow: hidden;
}
.card-media img {
display: block;
width: 100%;
max-width: 100%;
height: auto;
}
The declared dimensions should represent the image’s actual intrinsic ratio. If the file is 1600×1067, do not declare a 1600×900 box merely to remove a warning; use CSS or a deliberate crop when the design requires a different shape.
Keep meaningful alternative text
Lazy loading changes request timing, not the image’s meaning. Keep a useful alt value for informative images. For purely decorative images, an empty alt='' is preferable to exposing irrelevant text to assistive technology.
Use an explicit eager choice for critical media
<img
src='hero.webp'
loading='eager'
fetchpriority='high'
width='1920'
height='1080'
alt='A wide view of the product dashboard'
>
Here, loading states that the hero should not be deferred, while fetchpriority separately communicates its relative importance. Use the priority hint selectively rather than adding it to every image.
Which images should be lazy and which should stay eager?
| Image role | Recommended loading value | Reason |
|---|---|---|
| Hero or LCP image visible on first load | eager (or omit loading) |
It is part of the initial experience and should not be intentionally deferred. |
| First-screen logo or navigation mark | eager (or omit loading) |
It is normally visible immediately and is part of the page chrome. |
| Article images beginning below the opening section | lazy |
They are noncritical at the initial viewport. |
| Gallery cards lower in a long page | lazy |
The browser can defer work until the cards approach view. |
| A small image that is conditionally hidden but later revealed | Choose deliberately | Make sure it has a sized layout box and will become visible; otherwise a deferred request may not be triggered as expected. |
Do not add loading='lazy' mechanically to every <img>. The correct boundary is whether the resource is needed for the initial viewport, not whether it is large or small.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #3
What CSS can optimize besides fetching?
content-visibility: auto skips rendering work
CSS content-visibility: auto can let the browser skip layout and painting for off-screen content. That is a rendering-work optimization. It is not a replacement for the HTML loading attribute and should not be described as an image-fetch deferral mechanism.
.long-section {
content-visibility: auto;
}
| Control | What it addresses | What it does not promise |
|---|---|---|
img loading='lazy' |
Defers an image resource fetch until browser-defined conditions are met. | An exact, author-controlled pixel threshold. |
img loading='eager' |
Requests that the image not be deferred. | A higher network priority by itself. |
fetchpriority |
Communicates relative fetch priority. | Layout reservation or lazy behavior. |
content-visibility: auto |
May reduce off-screen layout and paint work. | Equivalent image-fetch deferral. |
What about CSS background-image?
Do not assume that a background image has a native, equivalent lazy-loading switch. content-visibility is documented as a rendering optimization, not a guaranteed background-image fetch deferral. If the image is meaningful content and you need the native loading hint, use an actual <img> element and style it with CSS. Reserve CSS backgrounds for decorative or layout-driven visuals when their loading behavior is acceptable without that guarantee.
Performance planning and measurement
Lazy loading addresses timing, not byte size
Images can dominate transfer costs: the HTTP Archive figure cited by web.dev reports that sites send more than 5 MB of images at the 90th percentile on both desktop and mobile (the passage does not state a study year). Deferring below-the-fold requests reduces what must compete during the first view, but it does not make an individual image file smaller. Choose appropriate dimensions and encoded formats for the slot as a separate optimization.
Check the initial viewport first
- Identify the image that is likely to become LCP and keep it eager.
- Confirm every deferred image has nonzero, accurate dimensions.
- Look for a large blank gap or content jumping as images arrive; both point to missing or incorrect reserved space.
- Test on a slow connection and a long page, because the browser’s threshold and available bandwidth affect when a deferred request begins.
Do not promise a fixed scroll distance
Because the browser calculates its own threshold, document your intent (“below-the-fold gallery images are lazy”) rather than writing a product requirement that depends on a particular number of pixels. A browser may fetch earlier or later while still conforming to the attribute’s purpose.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Troubleshooting lazy images
The image downloads immediately
Check whether it starts in or near the initial viewport. A browser is allowed to fetch a lazy image before it becomes visibly painted, and it chooses the threshold. Also verify that the markup actually contains loading='lazy' on the <img> element you are observing.
The page jumps when the image appears
Add accurate width and height attributes and make the CSS preserve the ratio with height: auto or an intentional aspect-ratio. Without a known box, surrounding content has no stable space to occupy.
A lazy image never appears
Inspect the element’s layout. A zero-sized or permanently hidden ancestor can prevent the image from intersecting a visible part of the page. Give the image a real layout size, ensure its src is valid, and confirm that the element becomes visible when the user reaches it.
The hero image feels slow
Remove loading='lazy' from an image expected in the initial viewport. Keep it eager and, when it is genuinely the most important request, consider a separate fetchpriority hint. Do not raise priority on every image.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
content-visibility did not defer the network request
That is expected. It can reduce layout and painting work for off-screen content, but it is not the documented control for deferring an <img> fetch. Add loading='lazy' to the image itself when fetch deferral is the goal.
Or skip the browser setup
If your actual task is to capture a page image or PDF rather than defer images in your own site, ScreenshotNeo provides a one-request website screenshot API. It can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
One-call cURL example (see the ScreenshotNeo API documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in 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)
And in 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}`);
ScreenshotNeo’s Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account to try it without entering a card.
FAQ
Does lazy loading change an image’s alternative text?
No. The alt value and the image’s HTML semantics remain the same; only the browser’s fetch timing is hinted.
Can a CSS utility class replace the loading attribute?
No. A class can control presentation, but the documented native fetch-defer control for an ordinary image is the HTML loading='lazy' attribute.
Frequently Asked Questions
Does lazy loading change an image’s alternative text?
No. The alt value and the image’s HTML semantics remain the same; only the browser’s fetch timing is hinted.
Can a CSS utility class replace the loading attribute?
No. A class controls presentation, while the documented native fetch-defer control is the HTML loading=’lazy’ attribute.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
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.

