Data URLs are composed of four parts: a prefix (
data:), a MIME type indicating the type of data, an optional
base64 token if non-textual, and the data itself:
mediatype is a MIME type string, such as
'image/jpeg' for a JPEG image file. If omitted, defaults to
If the data contains characters defined in RFC 3986 as reserved characters, or contains space characters, newline characters, or other non-printing characters, those characters must be percent-encoded (aka "URL-encoded").
If the data is textual, you can embed the text (using the appropriate entities or escapes based on the enclosing document's type). Otherwise, you can specify
base64 to embed base64-encoded binary data. You can find more info on MIME types here and here.
A few examples:
The text/plain data
Hello, World!. Note how the comma is percent-encoded as
%2C, and the space character as
base64-encoded version of the above
An HTML document with