On the Web mainly two raster graphics format are used – PNG and JPEG. They both have specific uses and are nearly useless in others.
PNG is used for computer generated graphics, i.e. everything that is not a photo. Most of these are generated from vector graphics formats, so SVG should be better for them, but most web browsers have better support for PNG.
Many years ago the GIF format was used instead of PNG. Then there were patents on an algorithm used for GIF compression, which led to the development of PNG. Now non-animated GIF is clearly obsolete, since PNG supports higher quality graphics (e.g. by having 24-bit colour or gamma correction) and has smaller file size due to better compression.
JPEG files are used only for photos. This is because they use a compression algorithm which decreases quality in a way visible in most graphics except photos. It also does not provide such features as alpha transparency which are useless for photos.
Compression algorithms for both PNG and JPEG may make many compressed files which can be decompressed to the same graphics (most compressed file formats have this property which has very uncommon uses). In case of PNG, there are several parameters selected by the compressing software. The choice of optimal values of these parameters is difficult without many slow trials, so there are programs like OptiPNG optimizing PNGs to decrease their size without any change in decompressed image. For JPEGs there are similar programs, e.g. jpegoptim. Both of these programs largely decreased sizes of some files which I recently used and generated by Inkscape or the GIMP.
