How to Embed Image Data using Data URIs

Posted by Lasantha Bandara on August 28th, 2016 File Under : html, image0 Comment

Data URIs can be used in your CSS files or inside HTML tags which saves the browser from having to make additional HTTP requests for the external resources, and can therefore increase page loading speed. Look at this image below, it is embeded into this page:


Normally, to display an image on your website you have to link to an external image file using the <img> element in HTML like this:

<img src="" />

When using a Data URI inside an image tag:


To use an image as a CSS background, CSS code will be like this:

background-image: url("");

When using a Data URI as a CSS Background:


How do you get a Data URI for an image?

There are many online tools to generate Data URIs. Use this Data URL Maker Tool. It's a drag and drop one.

File Under : html, image

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.