A data URL lets a document embed small files inline instead of linking to them. It is defined in RFC 2397 and looks like this:

text
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg…

The four parts

  • The data: prefix
  • The media type, such as image/png (defaults to text/plain)
  • The optional ;base64 flag
  • The encoded payload

When to use one

Data URLs shine for tiny assets like icons and single-pixel trackers, and for images returned by an API as text. They remove an extra HTTP request.

The limits

Base64 adds about 33% overhead, and a large embedded asset bloats the HTML and cannot be cached separately. Reserve them for small files and keep bigger pictures as normal resources.