Can I embed a .png image into an HTML page?

How can I embed a .png file into a blank “file.html” so that when you open that file in any browser you see that image?

In this scenario, the image file is not linked to from the HTML, but rather the image data is embedded in the HTML itself.


There are a few Base64 encoders online to help you with this, and this is probably the best I’ve seen:

As that page shows your main options for this are CSS:

div.image {

Or the <img> tag itself, like this:

<img alt="My Image" src="data:image/png;base64,iVBORwA<MoreBase64SringHere>" />

Leave a Reply

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