Sub topic 2
SVG: Icons, Logos, and Illustrations
This chapter assumes you can use a design tool, understand layers and frames, and know basic HTML and CSS. The focus is choosing an export that stays sharp, loads quickly, and behaves correctly in a browser.
SVG: Icons, Logos, and Illustrations
SVG (Scalable Vector Graphics) stores shapes, paths, and colors as text instructions rather than fixed pixels. It stays sharp when resized, so it suits icons, logos, diagrams, and simple illustrations.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-label="Add">
<path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2"/>
</svg>Use currentColor when an icon should inherit the surrounding text color. Remove hidden layers, unused metadata, and unnecessary editor information before handoff.
GIF: Why It Is Rarely the Right Choice
GIF supports simple animation and limited transparency, but it uses a small color palette. Photos and gradients often show banding or large file sizes. Use an animated WebP or AVIF when browser support and your toolchain allow it. Use GIF mainly for compatibility with an existing asset.
WebP: A Modern All-Round Format
WebP supports lossy and lossless compression, transparency, and animation. It often produces smaller files than JPEG or PNG at similar visual quality. It is a practical default for photographs, previews, and many transparent graphics.
AVIF: Higher Compression, With Trade-Offs
AVIF usually compresses photographs more efficiently than WebP. It can reduce transfer size, but encoding may take longer and some tools have weaker export support. Provide a fallback when your supported browsers or content pipeline require one.
Transparency and Animation Across Formats
| Format | Transparency | Animation | Typical use |
|---|---|---|---|
| SVG | Yes | Limited and script-dependent | Icons and logos |
| WebP | Yes | Yes | Modern web graphics |
| AVIF | Yes | Yes | Highly compressed images |
| JPEG | No | No | Photographs |
Choosing a Format for Each Image
- Choose SVG for scalable, shape-based artwork.
- Choose JPEG for photographs without transparency.
- Choose PNG when lossless detail or transparency matters and modern formats are unsuitable.
- Choose WebP for a broadly useful modern raster image.
- Choose AVIF when smaller files justify encoding and fallback work.
- Avoid GIF unless its compatibility or simple animation is specifically required.
Export Dimensions and 1x/2x Scales
Export raster images at the largest displayed size you need. A 400-pixel image displayed at 400 CSS pixels is 1x. A 800-pixel version displayed at 400 CSS pixels is 2x and looks sharper on high-density screens. Do not export every image at 2x automatically; compare the visual gain with the larger download.
Exercise
A logo is made from simple paths and must look sharp from 24 to 240 pixels. Which format should you export first, and when might you also provide a raster version?
Show answer
Export SVG first. Provide a raster version when a specific platform, email client, or fallback workflow does not support SVG.