File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Including images directly in HTML files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Including images directly in HTML files" Watch "Including images directly in HTML files" New topic

Including images directly in HTML files

Ruediger Waurig

Joined: Jul 24, 2001
Posts: 19
Hi there,
I've got the following question:
Usually placing an image in a HTML file is done by
<img SRC="myPicture.jpg">
<OBJECT type="image/jpg" data="myPicture.jpg">
But this means that there is an external file that contains the image, in this case myPicture.jpg
I don't want to have an additional external file that is referenced from within the HTML file. How can I manage to have the image be included directly in the HTML file itself?
I.e. when sending an e-mail in html format then the pictures are included in the same html file.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63544

No can do. HTML just doesn't do that.
E-mail messages that seem to "embed" images in HTML actually do no such thing. Rather, they are multi-part messages where the HTML is included in one part, and any "embedded" images are stored in other parts. The mail client peices it all together for display.

[Asking smart questions] [About Bear] [Books by Bear]
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

XML includes the ability to embed binary data, so in theory it may be possible in XHTML, but I really doubt that anyone has bothered to implement anything like this in the clients.
Like Bear says, HTML just doesn't do that.
I agree. Here's the link:
subject: Including images directly in HTML files
It's not a secret anymore!