How do you optimize images for SEO?
A source-checked guide to file names, alt text, compression, formats and image sitemaps, with a format table and a step-by-step checklist.
To optimize images for SEO, embed them with a real <img> element, give them short descriptive file names and accurate alt text, place them near relevant text, and serve compressed, correctly sized files in a modern format such as WebP or AVIF with a fallback. Then make sure Google can find them, with an image sitemap for images it might otherwise miss, and never lazy load the image that is your Largest Contentful Paint.
Everything below comes from Google Search Central, web.dev, MDN and the W3C, re-read on November 19, 2026. Where the docs are silent, such as on exact compression settings, we say so.
Key takeaways
- Use real image elements: Google finds images in the
srcof<img>, including inside<picture>, and does not index CSS background images. - Alt text matters most: Google calls alt text the most important image attribute. Describe the image in context and avoid keyword stuffing.
- File names are light clues:
my-new-black-kitten.jpgbeatsIMG00023.JPG, but names alone will not carry an image. - Prefer WebP or AVIF for raster images: MDN recommends them over JPEG, PNG and GIF, with a JPEG or PNG fallback via
<picture>. Use SVG for icons and diagrams. - Protect LCP: do not lazy load images in the first viewport, and consider
fetchpriority="high"on the likely LCP image. - Image sitemaps only need two tags:
<image:image>and<image:loc>. Caption, title, geo and license tags are deprecated.
Why does image SEO still matter?
Images appear in more places than the Images tab. Google’s image SEO best practices page (last updated March 2, 2026) lists text result images, Google Discover and Google Images as visual surfaces, and says the general recommendations for appearing in all of them are the same. In other words, one set of habits covers every surface.
Images also shape speed: Google says they are often the largest contributor to page size. web.dev’s lazy loading guide cites HTTP Archive data showing that images are the most requested asset type on most websites, and that at the 90th percentile sites send over 5 MB of images on desktop and mobile. Image work belongs in every technical SEO audit.
How should you embed images so Google can find them?
Use standard HTML image elements. Google states that it can find images in the src attribute of an <img> element, even when it is a child of other elements such as <picture>, and that it does not index CSS images. A product photo set as a background-image on a <div> is invisible to Google Images.
Always keep a fallback src
Responsive images use srcset or the <picture> element. Google notes that some browsers and crawlers do not understand these attributes, so it recommends always specifying a fallback URL in src. When you use <picture>, include an <img> with a src as the fallback, in line with the HTML Standard. A safe pattern looks like this:
<picture>
<source type="image/avif" srcset="black-kitten-800.avif">
<source type="image/webp" srcset="black-kitten-800.webp">
<img src="black-kitten-800.jpg" alt="Black kitten asleep on a gray wool blanket"
width="800" height="533">
</picture>
Reuse one URL per image
If the same image appears on many pages of a large site, Google recommends consistently referencing it with the same URL so it can cache and reuse the file instead of requesting it repeatedly. Image URLs also break quietly in redesigns, so include them in your website migration SEO checklist.
Supported formats
Google Search supports images referenced in an <img> src in BMP, GIF, JPEG, PNG, WebP, SVG and AVIF. Google also advises that the file extension should match the file type. Inline data URIs are allowed, but Google warns they can considerably increase page size.
What makes a good image file name?
Google describes the file name as giving “very light clues” about the subject of the image. Its guidance is short and practical:
- Use short but descriptive names:
my-new-black-kitten.jpgis better thanIMG00023.JPG. - Avoid generic names such as
image1.jpg,pic.gifor1.jpg. - If you localize images, translate the file names too, following Google’s URL encoding guidelines for non-Latin or special characters.
Rename files before upload, because renaming a live image changes its URL. And since the signal is light, fix missing alt text and surrounding copy first.
How do you write alt text for SEO and accessibility?
Google calls alt text “the most important attribute” for image metadata. It uses alt text together with computer vision and the page’s content to understand the image, and alt text on a linked image works as anchor text. The same text helps people using screen readers and people on low-bandwidth connections.
Google’s own ladder of examples is the clearest guide:
- Bad (missing):
<img src="puppy.jpg"/> - Bad (keyword stuffing): a long list such as “puppy dog baby dog pup pups puppies doggies…”, which Google says creates a poor experience and may cause the site to be seen as spam.
- Better:
alt="puppy" - Best:
alt="Dalmatian puppy playing fetch"
Practical rules for alt text
- Describe what the image shows in the context of the page, using a keyword only where it genuinely fits.
- For inline
<svg>, Google suggests a<title>element, referenced witharia-labelledby. - For purely decorative images (borders, ambiance, an icon next to link text that already says the same thing), the W3C’s decorative images tutorial recommends a null value,
alt="", so screen readers skip them.
Placement matters too. Google says it extracts information from page content, including captions and image titles, and recommends placing images near relevant text on pages relevant to the image subject. Our on-page SEO checklist covers the surrounding copy in more depth.
Which image format should you use?
MDN’s image file type and format guide gives a clear default: for raster images, prefer WebP or AVIF, which generally compress better than PNG, JPEG and GIF, and use <picture> to supply a PNG or JPEG fallback where needed. For diagrams, charts and icons that must render accurately at any size, use SVG. MDN advises lossless encoding for screenshots and line art; photos usually tolerate lossy compression.
| Format | Compression | Transparency | Best for | Notes from the docs |
|---|---|---|---|---|
| JPEG | Lossy | No | Photographs, as a fallback | MDN: good for lossy still images; JPEG has no alpha channel. Universally supported. |
| PNG | Lossless | Yes | Screenshots, line art, fallback for transparency | MDN: preferred over JPEG for precise reproduction or when transparency is needed. |
| WebP | Lossy and lossless | Yes | Most photos and graphics on the web | MDN: much better compression than PNG or JPEG; supports animation. |
| AVIF | Lossy and lossless | Yes | Photos where smallest size matters | MDN: slightly better compression than WebP, no progressive rendering; include fallbacks. web.dev: supported in Chrome and Opera since 2020, Firefox 2021, Safari 2022. |
| SVG | Vector (not pixel based) | Yes | Logos, icons, diagrams, charts | MDN: ideal for elements drawn accurately at any size. |
All five are on Google’s supported list, and its documentation does not rank formats for search. The choice is about file size and quality.
See which images are slowing down or hiding your pages
Run a free Klepha scan to spot missing alt text, oversized images and other technical issues that affect search and AI visibility. No guarantees, just a clear list of what to fix.
Run my free scanHow much should you compress and resize images?
Google wants sharp, high-quality images and fast pages. The way through is to stop shipping pixels nobody sees.
Resize to the displayed size
Serve multiple widths with srcset and sizes so a phone does not download a desktop hero. Google’s own example lists 320w, 480w and 800w versions of the same image with an 800w fallback in src. Chrome’s Lighthouse audits for properly sized images, modern formats and efficient encoding will flag the worst offenders.
Compress, then check by eye
web.dev notes that WebP, like JPEG, exposes a single quality value from 0 to 100 and recommends experimenting with encoder settings, for example in Squoosh, to see the trade-off between file size and quality. None of the primary sources prescribe a universal quality number or a maximum file size, so treat any fixed rule you see online with caution. Compare against the original at display size and stop where artifacts appear.
Use caching and an image CDN
web.dev’s Optimize LCP guide recommends a CDN to shorten the distance files travel, notes that image CDNs usually apply size reductions automatically, and recommends an efficient cache-control policy so repeat visitors load images from cache. If your images live on a CDN domain, Google’s image sitemap documentation asks you to verify that domain in Search Console.
How do lazy loading and LCP affect image SEO?
Largest Contentful Paint (LCP) is one of the three Core Web Vitals, and on many pages the LCP element is an image. web.dev says sites should strive for an LCP of 2.5 seconds or less for at least 75% of page visits.
Lazy load below the fold only
Browser-level lazy loading with loading="lazy" defers offscreen images until the user scrolls near them, and browsers that do not support it simply ignore the attribute. But web.dev is explicit: images visible in the first viewport, and especially LCP images, should use the browser’s default eager loading.
Make the LCP image discoverable and prioritized
- Put the LCP image in the initial HTML as an
<img>with itssrcorsrcsetpresent, so the browser’s preload scanner finds it. Images injected by JavaScript, or hidden behinddata-srcby a lazy loading library, cannot be discovered early. - Add
fetchpriority="high"to the image most likely to be the LCP element. web.dev warns that setting high priority on more than one or two images makes it unhelpful. - If the LCP image is only referenced from CSS or JavaScript, preload it with a high fetch priority.
Reserve space with width and height
web.dev recommends width and height attributes on all <img> tags so the browser can reserve space and avoid layout shifts. For wider Core Web Vitals triage, see how to fix technical SEO issues.
Do you need an image sitemap?
Not always, but it helps when Google might miss images. Google’s Image sitemaps documentation (last updated December 10, 2025) describes them as a way to tell Google about images it might not otherwise find, such as images your site loads with JavaScript. You can create a separate image sitemap or add image tags to your existing sitemap; Google says either approach is equally fine.
The required tags
<image:image>encloses information about one image. Each<url>can contain up to 1,000 of them.<image:loc>is the image URL. It can be on another domain (for example a CDN) as long as you verify both domains in Search Console, and robots.txt must not block the images you want indexed.
Google has removed <image:caption>, <image:geo_location>, <image:title> and <image:license> from its documentation, per a 2022 deprecation announcement. If your CMS still outputs them, they are not needed for Google. Here is a minimal example adapted from Google’s documentation:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com/kittens/black-kitten</loc>
<image:image>
<image:loc>https://cdn.example.com/img/black-kitten-800.jpg</image:loc>
</image:image>
<image:image>
<image:loc>https://cdn.example.com/img/black-kitten-playing.jpg</image:loc>
</image:image>
</url>
</urlset>
Note that <loc> is the page URL and <image:loc> is the image URL. General sitemap best practices also apply; submit it in Search Console and check the sitemap report for errors.
How do landing pages and metadata help images rank?
Google says the content and metadata of the page where an image is embedded can greatly influence how and where the image appears. Three levers stand out in its documentation:
- Preferred image metadata. Google’s choice of preview image is automated, but you can influence it with the schema.org
primaryImageOfPageproperty, animageproperty on the main entity, or theog:imagemeta tag. Pick a representative, high-resolution image, not a logo, text image or extreme aspect ratio. - Titles and descriptions. Google uses the page’s
titleand meta tags, among other sources, for image result titles and snippets. See our guide to writing meta titles and descriptions. - Structured data. Structured data can make images eligible for certain rich results in Google Images, and the
imageproperty is required for those badges. Our schema markup guide explains how to add it without errors.
Clear, crawlable, well-described pages also help with AI search; see our search and AI visibility solutions, our expertise and our case studies.
Step-by-step image SEO checklist
Work through these per template (product, article, category), not image by image.
- Audit how images are embedded. Replace content images set as CSS backgrounds with
<img>elements, and make sure every<picture>orsrcsethas a fallbacksrc. - Rename files before upload. Use short, descriptive, hyphenated names and translate them on localized pages.
- Write alt text in context. Describe the image as it relates to the page, avoid keyword lists, and use
alt=""for decorative images. - Place images near relevant text. Add captions where they help readers understand the image.
- Choose the right format. WebP or AVIF for photos with a JPEG or PNG fallback, SVG for logos, icons and diagrams, lossless for screenshots.
- Resize and compress. Generate several widths for
srcset, compress until just before artifacts appear, and serve from a CDN with long cache lifetimes. - Set width and height. Add dimensions to every
<img>to prevent layout shifts. - Handle loading priority. Use
loading="lazy"only below the fold, keep the LCP image eager and in the initial HTML, and addfetchpriority="high"to it. - Add an image sitemap if needed. List images Google may not find, using only
<image:image>and<image:loc>, and verify any CDN domain in Search Console. - Set preferred image metadata. Add
og:imageand schema.org image properties that point to a representative, high-resolution image. - Measure. Check PageSpeed Insights field data for LCP and use Search Console to confirm sitemaps process without errors.
Sources
- Google Search Central: Google image SEO best practices: developers.google.com/search/docs/appearance/google-images. Supports img element indexing, no CSS image indexing, src fallbacks, supported formats, file name and alt text guidance, preferred image metadata and structured data. Last updated March 2, 2026; accessed November 19, 2026.
- Google Search Central: Image sitemaps: developers.google.com/search/docs/crawling-indexing/sitemaps/image-sitemaps. Supports required tags, the 1,000 images per URL limit, cross-domain image URLs, deprecated tags and the sitemap example. Last updated December 10, 2025; accessed November 19, 2026.
- web.dev: Browser-level image lazy loading for the web: web.dev/articles/browser-level-image-lazy-loading. Supports eager loading for first-viewport and LCP images, width and height attributes, and the HTTP Archive image weight figure. Last updated August 13, 2024; accessed November 19, 2026.
- web.dev: Optimize Largest Contentful Paint: web.dev/articles/optimize-lcp. Supports the 2.5 second LCP target, resource discovery, fetchpriority, CDNs and caching. Published April 30, 2020, last updated March 31, 2025; accessed November 19, 2026.
- web.dev Learn Images: WebP and AVIF: web.dev/learn/images/webp and web.dev/learn/images/avif. Support WebP capabilities and quality settings, and AVIF browser support history. Last updated February 1, 2023; accessed November 19, 2026.
- MDN Web Docs: Image file type and format guide: developer.mozilla.org. Supports format recommendations, lossy versus lossless guidance and the format comparison table. Accessed November 19, 2026.
- W3C WAI: Decorative images tutorial: w3.org/WAI/tutorials/images/decorative. Supports using a null alt value for decorative images. Accessed November 19, 2026.
Frequently asked questions
Does alt text help images rank in Google?
Yes, it is one of the signals Google uses. Google calls alt text the most important attribute for image metadata and uses it with computer vision and page content to understand an image. Write a short, accurate description in context and avoid stuffing it with keywords.
Do image file names matter for SEO?
A little. Google says file names give very light clues about an image's subject, so a short descriptive name such as black-kitten.jpg is better than IMG00023.JPG. Alt text, captions and nearby text matter more.
Is WebP or AVIF better for SEO?
Google Search supports both, along with JPEG, PNG, GIF, BMP and SVG, and does not rank one format above another. MDN notes AVIF usually compresses slightly better while WebP has broader support and progressive rendering, so many sites serve AVIF or WebP with a JPEG fallback through the picture element.
Do I need an image sitemap?
Only if Google might not find your images otherwise, for example images loaded with JavaScript or hosted on a CDN. Google says you can add image tags to an existing sitemap or create a separate one. Only the image:image and image:loc tags are required.
Should I lazy load all images?
No. web.dev recommends lazy loading only images outside the first viewport. Images visible on load, especially the Largest Contentful Paint image, should load eagerly, and the LCP image can be given fetchpriority high.
Does Google index CSS background images?
No. Google states that it does not index CSS images. Use an img element, optionally inside a picture element, for any image you want to appear in Google Images or Discover.