A Data URI combines the MIME type and Base64 payload in one string. It can help with tiny self-contained assets, but large images inflate source and lose independent caching.
Convert an image to a Data URI
Make a self-contained text representation for prototypes, small icons, or debugging. Large photos are usually better as files.
Choose an image
Converted locally in this browser
Build the correct wrapper
HTML img elements and CSS url values both accept a Data URI. The MIME type must match the decoded bytes, and the Base64 flag tells the browser how the payload is represented.
Keep accessibility in HTML
Embedding changes the source location, not the meaning of the image. Informative HTML images still need useful alt text, while decorative images should be marked so assistive technology can skip them.
Use normal files for substantial images
Base64 adds representation overhead and the embedded bytes cannot be cached separately from the document or stylesheet. Product photos, article images, and responsive assets usually belong at ordinary URLs.