Embed base64 encoded images

Most modern desktop browsers such as Chrome, Mozilla, Internet Explorer supports images encoded as data url. But there are problems displaying data URLs in some mobile browsers like Android Stock Browser.

Here we are presenting that how we can embed base64 encoded images in various platforms. This is similar to how you embed an image in a HTML email message.

Embed base64 encoded images

Syntax:

Example in HTML:

Example in CSS-Background image:

Example in PHP-convert image to Base64 string:

Example in C#-convert image to Base64 string:

With this technique we can prevent multiple HTTP requests, reducing the loading time of a web page.

Note:
The image is base64 encoded, so it is much larger than it’s binary sibling. This makes the use of this rather limited.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.