designwithfocus

On-page SEO

How to Optimize Images for SEO

By Design With Focus Team 6 min read
An image file renamed with a short description and an alt text label

Short answer

Use a normal img element, a short descriptive file name, and alt text that describes the picture without stuffing keywords. Google's image guide lists BMP, GIF, JPEG, PNG, WebP, SVG, and AVIF, and it says CSS images are not indexed. Add structured data or og:image when you want to influence the preview.

Last verified against the sources listed below.

Key takeaways

  • Google says it can index an img src, including inside picture, and it does not index CSS images.
  • Supported formats in that guide are BMP, GIF, JPEG, PNG, WebP, SVG, and AVIF.
  • A name like my-new-black-kitten.jpg is clearer than IMG00023.JPG.
  • Alt text should describe the image. Keyword stuffing can be treated as spam.
  • The image guide was last updated March 2, 2026.

How to optimize images for seo is a file, a name, and a sentence of alt text, in that order. Google’s image guide, last updated March 2, 2026, says the same recommendations cover image results, Discover, and the images shown with text results.

Technical SEO still has to let the crawler fetch the URL. This page stays with the image guide’s own list: discovery, the landing page, names, alt text, formats, and structured data.

What should you publish?

Put the image in HTML, name the file, and describe it.

  1. Use an img element with a src. Do not rely on a CSS background for an image you want indexed.
  2. Give the file a short descriptive name, and match the extension to the type.
  3. Write alt text that describes the image in the context of the page.
  4. Choose a supported format and avoid a huge file when a smaller one is still clear.
  5. If you use srcset or picture, keep a fallback src on the img.
  6. Point structured data or og:image at a representative preview when you care which image is chosen.
  7. Compress the file, then check the page in PageSpeed Insights as the guide suggests.

Run the file through the image compressor before upload. The guide says high-quality photos beat blurry ones, and it also says images are often the largest part of a page.

JPG is one of the formats on the supported list. So are PNG, WebP, GIF, BMP, SVG, and AVIF.

Which markup can Google see?

An img src can be indexed. A CSS image cannot.

The guide’s good example is an img with src and alt. The bad example is a photo that exists only as CSS. Google can find an image even when the img is inside another element, including picture.

Some browsers and crawlers do not understand srcset or picture, so the guide says to always provide a fallback src.

A srcset example on that page lists the same photo at 320, 480, and 800 pixels wide, with a sizes attribute and a fallback src. A picture example offers SVG, then WebP, then a PNG img with alt text. The guide points at section 4.8.1 of the HTML Standard for that fallback.

Copy the pattern: every source list ends in a real img.

You may inline a file as a data URI. The guide says to judge that carefully because the page can get much larger. A photo you want in image search is a normal URL.

How should the file be named?

Use a short name that says what the picture is.

Google says the file name gives a light clue. Its example prefers my-new-black-kitten.jpg over IMG00023.JPG. It says to avoid names such as image1.jpg, pic.gif, and 1.jpg.

If you localize the page, translate the file name too, and follow URL encoding for non-Latin characters. Sites with thousands of images may need to generate those names. The extension should still match the type.

The W3C PNG specification, a Recommendation dated June 24, 2025, describes PNG as a lossless raster format. That is the format behind a .png name. Google’s list is what decides eligibility.

The specification is what the bytes mean. MDN describes alt as the text a browser may show when the image is not displayed, which matches the guide’s accessibility reason for writing it.

Put the image near relevant text, on a page about the same subject. The guide says Google also reads captions and titles on the page. The file name is the light clue.

The surrounding copy is the stronger one.

What belongs in the alt attribute?

A description of the image, not a list of keywords.

The guide calls alt text the most important attribute for extra metadata, and it says Google uses it along with computer vision and the page content. It also helps people who use screen readers or who have a slow connection. If the image is a link, the alt text can act as the anchor.

The bad pattern is an empty description when the image is content, or a string of repeated keywords. The guide says keyword stuffing is a poor experience and may cause the site to be seen as spam. Write one useful description that fits the paragraph beside the picture.

The guide also points at W3C guidance for accessibility, including a title inside an inline svg when that is the graphic.

When do you add structured data?

Add it when you want a chance at the image rich results the guide describes.

Google says the preview image is chosen automatically from several sources. You can influence it with schema.org primaryImageOfPage on a WebPage, with an image on the main entity, or with og:image. The guide’s practices for that choice: use a relevant, representative image, skip the logo and images that are mostly text, avoid an extreme aspect ratio, and prefer high resolution.

Structured data has its own rules. The image guide says to follow the general structured-data guidelines and the rules for the specific type, or the markup may be ineligible. For the image badge and rich result it describes, the image attribute is required.

Title and meta description on the landing page still matter, because Google generates the title link and snippet from sources that include those tags.

An image sitemap can list files the crawler might not find, including files on another domain, which is how a CDN fits. Verify the CDN in Search Console if you want crawl-error reports. Use one stable URL for an image that appears on many pages so Google can reuse the cached file.

What if the image still fails?

Match the symptom to the line in the guide.

What you see Likely miss What the guide says to do
Image never indexed It exists only in CSS Use an img src
Weak understanding of the subject Generic file name or missing alt Rename the file and describe the image
Spam concern Alt text repeats keywords Write a normal description
Wrong preview Logo or a very wide banner in og:image Pick a representative image at a normal ratio
Responsive swap fails srcset or picture without a fallback src Always include src on the img
Slow landing page The image dominates the download Optimize the file and check PageSpeed Insights

web.dev’s Web Vitals page says a good Largest Contentful Paint is within 2.5 seconds for the 75th percentile of loads. The image guide does not set that number. It does say a heavy image makes the page slow, and it sends you to PageSpeed Insights.

Shrink the file, keep the HTML, and use the name and the alt text as clues rather than as a place to stack keywords.

Frequently asked questions

Does Google index a CSS background image?

No. Google's image SEO guide says standard HTML image elements help crawlers, and that Google can find an image in the src of an img element, including when that img is inside another element such as picture. It says Google does not index CSS images. If the picture is content, put it in HTML. A background in a stylesheet can still be decoration.

Which formats can appear in Google images?

The guide lists BMP, GIF, JPEG, PNG, WebP, SVG, and AVIF for images referenced from an img src. It also says the file extension should match the file type. You can inline an image as a data URI, and the same page warns that inlining can make the page much larger even though it removes a request. Use a normal file URL for a photo you hope to rank.

How long should alt text be?

The guide does not publish a character limit. It says alt text is the most important attribute for telling Google what the image is about, and that it also helps people who cannot see the image. Write useful text that matches the page. The bad example is missing alt text. Another bad example is stuffing keywords. A better example describes the subject.

Do I need structured data for every image?

Only if you want the rich-result treatment the guide describes. It says structured data can make images eligible for certain rich results, including a badge in Google Images, and that the image attribute is required for those types. It also shows primaryImageOfPage on a WebPage, an image property on the main entity, and an og:image meta tag as ways to suggest a preview. The selection is still automatic.

Can a CDN host the image file?

Yes. Google's image sitemap notes say image sitemaps, unlike regular sitemaps, may include URLs from other domains in the image location, which is how a CDN fits. The guide encourages you to verify that CDN domain in Search Console so crawl errors are reported. It also says to refer to the same image URL everywhere, so Google can cache the file instead of fetching duplicates. Compress the file first.

Sources