Image attributes cheat sheet

Image attributes that affect speed or search: width, height, alt, srcset, sizes, loading, fetchpriority and decoding, plus how Chrome ranked a hero image.

BeginnerReference4 min readUpdated October 30, 2026

In this guide
  1. The attributes
  2. A complete example
  3. How Chrome ranked the main image
  4. Choose in two questions
  5. Mistakes to avoid
  6. Check your own page
  7. Sources

The attributes

AttributeWhat it doesUse it whenWatch out
`src`The address of the image. Needed even with srcsetAlwaysKeep the real address in the HTML. Do not hide it in data-src for the main image
`width` and `height`The image's intrinsic size in pixels, with no unit. The browser uses the ratio to reserve space before the file arrivesAlways, on every imgCSS may scale the picture. The attributes still set the ratio
`alt`Text that stands in for the image. alt="" marks a decorative imageAlways. Describe the content or the job. Empty for decorationA missing alt is different from an empty one
`srcset`A list of image files with their real widths (w) or pixel densities (x)The image is shown at different sizes or on different screensA w value must match the file's real width. Do not mix w and x
`sizes`How wide the image will be in the layout. Used with w descriptors. Defaults to 100vwYou use srcset with w valuesDescribes the layout, not the viewport. MDN also lists an auto keyword
`loading`eager (default) loads now. lazy waits until the image is near the viewportlazy for images below the first screenNever lazy for the main image. Only works with JavaScript on
`fetchpriority`A hint of the priority relative to other images: high, low or autohigh for the likely LCP image, one or two per pageIf everything is high, nothing is. low for off-screen carousel slides
`decoding`A hint about when to decode: sync, async or auto (the default)RarelyMDN says the effect is hard to perceive on static images
`<picture>` and `type`Lets the browser pick the first format it understandsOffering AVIF or WebP with a JPEG fallbackThe inner img is required and carries alt

See responsive images, lazy loading and image width and height.

A complete example

<img src="/img/hero-1200.avif"
     srcset="/img/hero-600.avif 600w, /img/hero-1200.avif 1200w"
     sizes="100vw"
     width="1200" height="675"
     alt="The shop front on a sunny morning"
     fetchpriority="high">

For an image below the first screen, change fetchpriority="high" to loading="lazy".

How Chrome ranked the main image

I loaded ten small test pages in Chrome for Testing 153 and recorded the priority of the image request when it was made, and any change after. These are observations of one browser build, not rules, and other browsers differ.

How the image was writtenPriority when requestedLater
<img>, nothing addedMediumHigh, once it was seen to be in the viewport
<img fetchpriority="high">High
<img fetchpriority="low">Low
<img loading="lazy">Lowstayed Low
<img loading="lazy" fetchpriority="high">High
<img> far below the first screenMedium
<picture> with an img insideMediumHigh
A CSS background-imageLowHigh
An image inserted by a scriptLowHigh
<link rel="preload" as="image"> with nothing elseLowHigh, once the page used it

Three things stand out. A plain img starts at Medium and rises, so fetchpriority="high" mainly changes where it starts. Background images, script-inserted images and a bare preload all start at Low. And loading="lazy" starts at Low and stays there, which is why it hurts the main image. The 2025 Web Almanac makes the same point about preload, saying that it should be combined with fetchpriority="high" to ensure the image is fetched at high priority. See how to fix slow LCP.

Choose in two questions

QuestionAnswer
Is this the main image at the top of the page?Put it in the HTML as an img, add fetchpriority="high", never loading="lazy"
Is it below the first screen?Add loading="lazy", and keep width and height

Mistakes to avoid

Check your own page

Run the free audit and find the Largest Contentful Paint element. Look at its markup against the first table, and in the Network panel add the Priority column to see what Chrome gave it.

Sources

Start here

Free website audit

Live Google data for any public page: mobile and desktop.

Mobile + desktop · Lighthouse lab test · Real-user Chrome data when Google has it

Rather have this done for you? Speed optimization · Book a call

Related guides

All guides →