knowledge/technology/internet/Data URLs.md

18 lines
17 KiB
Markdown
Raw Normal View History

2023-12-04 10:02:23 +00:00
---
source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
obj: concept
---
# Data URLs
2024-01-17 08:44:04 +00:00
**Data URLs**, URLs prefixed with the `data:` scheme, allow content creators to embed small files inline in documents.
2023-12-04 10:02:23 +00:00
## Syntax
2024-01-17 08:44:04 +00:00
Data URLs are composed of four parts: a prefix (`data:`), a [MIME](../files/MIME.md)-type indicating the type of data, an optional `base64` token if non-textual, and the data itself:
2023-12-04 10:02:23 +00:00
`data:[<mediatype>][;base64],<data>`
2024-01-17 08:44:04 +00:00
The `mediatype` is a [MIME](../files/MIME.md) type string, such as `'image/jpeg'` for a JPEG image file. If omitted, defaults to `text/plain;charset=US-ASCII`
2023-12-04 10:02:23 +00:00
The image below is actually a data url:
![image](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhQAAABPCAYAAACzrFz4AAAACXBIWXMAAAAAAAAAAQCEeRdzAAAQAElEQVR4nO2daXAcx5Xn+8N8mA+e2A8z4QhHOHZiZh2OWXvt8dqe8foY25JtWbIsy5ItaSxLlizJkqz7lnVSsg5TlKiDEk+RFO8DAAEQIAjiBkjc4CGQAO8TAE9QvACCAAgyt3/ZeIVEobrRjRvk+0e86OrKqqzMrMyX/3wvKzNUUFBgkLy8PE9yc3M9yc/PN3JNYWGh/f/pp5+a8YT2tnOms6PTtB48Y5Z8fZr5+POTrCR/f45ZP3FdzHsvdp03834YMm3HD9n/9UnvmdUPft8LL3r5t2b99Gf63LcnZ6GZf8XfmYU//Xv7m/f01b3C856+xtTOf20IchfBsc86zb/8ZIPpPH/ROzdp9kHzpas2mn+7ZpP5zcPbbbiL7/73Zhvu3pNbdspej1x5R539Ldt4xoZ956bN5qu/3GS+/qtPbdjhY53efVxDmDxvTspRL4zrJQ4Xtz6504aRLu7heENdq3npgwbz7d/U2rgIu+/lPb3uO3HqvPnxH+ps+FV313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