Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a file format which integrates all HTML content itself in one file?

Instead of doc, docx, odt or pdf, I want to use HTML5 documents to author my content. But that poses a problem when I want to send the HTML files for instance by email; I'd have to zip it and then attach it to an email. Of course, there is .lit and .chm, but for obvious reasons that's not the way to go. Also, it's possible to inline javascript and CSS code in HTML files. This has drawback too: images are still excluded, and embedding all external CSS and Javascript files into one HTML file is cumbersome. Tools can automate this, but then the image problem still exists.

The most important motivation to use HTML over pdf/doc/docx/odt is that HTML is not designed for print, whereas pdf/doc/docx/odt all are (and thus not optimized for screenreading). Also, HTML is a fully accepted and open standard, which cannot be said of the named formats (odt is open but not widely accepted).

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Embedding everything in a normal HTML file is the way to go. Have you ever seen TiddlyWiki? I think I've seen it refered to as a "Single Page Application" - everything is embedded in one HTML file, so it functions as (well, almost) a stand alone piece of software. I don't use it, but I think it's technically quite impressive.

Images can be included inline using in base64 encoding using a Data URI. But support in Internet Explorer 8 is not complete (there's a size limit IIRC), and support missing entirely on older versions of IE. Most other modern browsers have good support.

Note that this will generally increase the size of the image by about a third (because you only "use" 6 out of every 8 bits per byte, so have to use a third more bytes to accomodate that gap).

For example, you get something like this:

<img src="data:image/png;base64,<BASE64 STRING>" />

Or this:

.someClass
{
    background-image:url(data:image/png;base64,<BASE64 STRING>");
}

You might also wish to have a read of the Wikipedia article on Data URIs, it has comments regarding browser support and some examples of usage.

share|improve this answer
    
Are there any tools (gems, eggs, node packages, etc.) that handle the converting and including? Is there a tool that will inline JS and CSS where it sees a src="..." or href="..." attribute? And then convert images to base64 and replace the <img src="..." with <img src="data:image/..."? –  Sukima Aug 22 '13 at 14:39
    
I've no idea, I've not tried to wrap something up like this before to ever have a need to look. –  DMA57361 Aug 22 '13 at 14:50

I think the MHTML format (MIME HTML) (.MHT file extension) is probably what you are after. This embeds everything in a single file (much like an HTML email). Images etc. are embedded with base64 encoding.

Browser support is reasonable. IE and Opera can Save and View MHT files. In IE you simply "Save As..." and select "Web Archive, single file (*mht)". However, Firefox and Chrome require browser extensions.

Personally, I would probably upload the HTML content to a website (possibly password protected) and just distribute the link. MHT files are not exactly user editable, so require regeneration when you want to distribute. Once it's all been combined into an MHT file, is it still as accessible as HTML?

PDF is reasonably accessible. It has it's own screen reading capabilities. Not sure how it handles images though - unless may be you create this with a specific tool?

share|improve this answer
    
Apart from technical requirements, there is also an organizational requirement not to work with any proprietary standard (pdf may be open, it's still proprietary). I'll look into mhtml though. –  user45971 Aug 12 '10 at 13:31
    
See tools.ietf.org/html/rfc2557. It's an open standard. It surprised me that IE had better support than Firefox (the latter preferring its own proprietary format), but there you have it. There is probably better tool support for pdf or html+dependancies though. –  michaelc Sep 8 '11 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.