What Are Data URIs?
A data URI embeds file content directly in HTML or CSS, eliminating an HTTP request. Format: data:[mediatype];base64,[data]. Ideal for small images like icons, logos, and UI elements.
When to Use Base64 Images
- Small images under 10KB (icons, bullets, simple graphics)
- Email HTML templates (images often get blocked — inline ones don't)
- Single-page applications reducing HTTP requests
- CSS background images that need to load instantly
- Offline-capable web apps
When NOT to Use Base64 Images
Large images (photos, banners) should not be Base64 encoded. The 33% size increase plus lack of caching makes them slower than regular image files. Use Base64 only for images under 10KB.
Frequently Asked Questions
Does Base64 affect page load speed?
For small images it speeds things up (fewer HTTP requests). For large images it slows things down (increased HTML size, no caching).
How do I use a Base64 image in HTML?
Use: <img src="data:image/png;base64,iVBOR...">. Replace the Base64 string with your encoded image data.