.png
Example
<img src="sneaker-cutout.jpg" alt="Red sneaker"
width="600" height="600"><picture>
<source srcset="sneaker-cutout.webp" type="image/webp">
<img src="sneaker-cutout.png" alt="Red sneaker" width="600" height="600">
</picture>A cutout needs transparency: PNG keeps it losslessly, and WebP keeps it at a smaller size.
Common mistakes
- Using PNG for photos, making files several times larger than needed.
- Exporting icons as PNG instead of SVG, so they blur when scaled.
Key points
- PNG is used for images that need transparency or sharp edges, not photos.
- Large PNGs are optimized or also offered as WebP or AVIF.
Interview questions
Is PNG lossless?
Yes. PNG compression never loses data, though tools may reduce colors to a palette before saving to make files smaller.
What is the difference between PNG-8 and PNG-24?
PNG-8 uses a palette of up to 256 colors and is smaller. PNG-24 stores full color, and PNG-32 adds an alpha channel.