Use JPG for photographs where small file size matters, PNG for graphics that need sharp edges or transparency, SVG for logos and icons, and modern formats such as WebP or AVIF wherever supported, since they usually give smaller files at similar quality. Compress every image, serve sizes that match the screen and lazy-load images below the fold.
- ✓JPG suits photographs; PNG suits sharp graphics and transparency
- ✓SVG is ideal for logos and icons
- ✓WebP and AVIF usually give the smallest files
- ✓Always compress and resize images for each screen
- ✓Image choices directly affect page speed and SEO
Why image formats matter
Images are usually the largest files on a web page. A single uncompressed photograph can weigh more than all the text, code and styles combined. When images are too large or in the wrong format, pages load slowly, especially on mobile networks, and visitors leave before they see the content. Slow pages also perform worse in search, because loading speed is part of how search engines judge page experience.
Choosing the right format for each image, and preparing it properly, is one of the simplest ways to make a website faster. The difference between a well-optimised image and a poorly prepared one can be several megabytes, with no visible change in quality. Our post on UX and website traffic explains how page speed affects search and conversion.
JPG vs PNG at a glance
When to use JPG
JPG, also written JPEG, uses lossy compression that is very good at shrinking photographs. It removes detail that the eye is unlikely to notice, so files can be much smaller than lossless formats. JPG is a good choice for photographs, product images and other complex pictures with many colours and gradients. Avoid it for images with sharp edges, text or flat colours, where compression can create visible blurring or blocky artefacts.
When to use PNG
PNG uses lossless compression, preserving every pixel exactly. That makes it ideal for screenshots, interface graphics, diagrams, illustrations with flat colours and any image that needs a transparent background. However, PNG files for photographs are usually far larger than the same photo saved as JPG or a modern format, so avoid using PNG for photography on websites.
Modern formats: WebP and AVIF
WebP and AVIF are newer image formats designed for the web. Both support lossy and lossless compression as well as transparency, and they usually produce noticeably smaller files than JPG or PNG at similar visual quality. Modern browsers support WebP widely, and AVIF support has grown significantly. Many websites now serve WebP or AVIF by default, with JPG or PNG as a fallback for older browsers.
SVG for logos and icons
SVG is a vector format that describes shapes rather than pixels, so it stays perfectly sharp at any size and is often very small. It is the best choice for logos, icons and simple illustrations. SVGs can also be styled and animated with code. Avoid SVG for photographs, which cannot be represented efficiently as vectors.
What about GIFs?
GIF is an old format still used for simple animations, but GIF files are often very large and limited to 256 colours. For animated content on websites, short video files such as MP4 or WebM, or animated WebP, usually look better and load much faster. For simple interface animations, CSS or lightweight vector formats such as Lottie are even more efficient.
Optimising images
-
1
Choose the formatPhoto, graphic, icon or transparency need.
-
2
ResizeExport images at the size they will be displayed, plus a version for high-density screens.
-
3
CompressUse compression tools to reduce file size without visible loss.
-
4
Serve responsivelyProvide several sizes so each device downloads the right one.
-
5
Lazy-loadLoad images below the first screen only when needed.
-
6
Set dimensionsSpecify width and height to prevent layout shifts.
These steps help pages pass Core Web Vitals, particularly loading speed and visual stability. Our guide to responsive web design explains how to serve different image sizes to different screens.
Accessibility and images
Whatever the format, images need meaningful alternative text so screen reader users understand their content and purpose. Decorative images should have empty alternative text so they are skipped. Avoid putting important text inside images, since it cannot be resized, translated or read by assistive technology as easily as real text. Our guide to accessibility in UI/UX design covers these requirements.
Quick reference
- Photographs: WebP or AVIF, with JPG fallback
- Screenshots and UI graphics: PNG or lossless WebP
- Logos and icons: SVG
- Images with transparency: PNG, WebP or AVIF
- Animations: video formats or animated WebP rather than large GIFs
