Is it possible to have html code and all images in one file?

I want to have an html file with javascript. Then I want to have some images in this file. I want to send this html file to my friends (via email). I want them to see my html image file, but I do not want to send them all the files with all the images. It would be nice to send them to only one file.

I also do not want to have images on a web server.

I also do not want to send them an archive with all the files (since then they need to open this archive).

I want a lot or is it possible to do what I want?

ADDED

I do not want my friends to see the html file in the mail client. I want to send the file as an attachment. That way, they can save it and then open it using a browser.

+3
source share
7 answers

Yes, it is possible:

# HTML
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA................." />

# CSS
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA.................)

The file source is encoded using the Base64 algorithm, which makes it easy to represent binary data as plain text.

Learn more about wikipedia: Data URI Scheme .

+5
source

Depending on whether the mail client supports it, theoretically you can use a URI scheme for example:

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

, . . X . Etcetera. , . HTML. , , - .


OP: , -. Wikipedia .

URI -:

  • Gecko, Firefox, XeroBank, Camino, Fennec K-Meleon
  • Konqueror, / KDE KIO
  • Opera ( , Nintendo DSi Wii)
  • WebKit, Safari ( iPhone), Android, Epiphany Midori (WebKit Konqueror KHTML, Mac OS X KIO, ), Webkit/Chromium, Chrome Iron
  • Internet Explorer 8. "" , , , JavaScript, URI , script , - . URI 32 KiB.

, IE8 32 . , , URI IE8. IE7 .

+3

, , 100% , .

? , ? (- http://www.text-image.com/)

, .

0

javascript . , , .

.

0

html (zip tarball, )?

0

If you just want to send one file, just write it using your favorite compression program.

0
source

You should by no means send emails whose body is HTML. Send plain text mail with images as MIME attachments or, even better, put images on a website (I hear that Flickr is not bad ;-) and send them URLs.

I am going to say it again because it needs to be said more often: email should be plain text.

-4
source

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


All Articles