Is it possible to make an image using html?

I have control on a page that receives html from a text file and displays that html on a web page. Right now he should add an image somewhere and reference this src image.

I was wondering if it is possible to display an image along with other html code, is this possible?

+3
source share
4 answers

Yes it is. You need a data URI scheme :

<img src="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" />

The same thing can be done in CSS:

ul.checklist > li.complete { margin-left: 20px; background:
  url('data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAA
ABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/5
8ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/A
FGGFyjOXZtQAAAAAElFTkSuQmCC') top left no-repeat; }
+8
source

You can use inline SVG . See this article for mozilla , and this one for IE .

+3
source

You can also create images using CSS characters and different characters and play with z-indexes. Here's the CSS Homer .

+2
source

I saw this by creating a table with one cell for each pixel, setting the background color of the cell to the color of the pixel.

+1
source

Source: https://habr.com/ru/post/1709841/


All Articles