
: Re: What is the minimum required content for a valid ePub? I would like to create my own ePub documents from scratch without a tool so that I have full control over the final result. What is
Here's an epub 3.0 file that validates with epubcheck 3.0.1 (the current version at the time of writing). There's plenty more info that can (and should) go in there, of course, but you asked for minimums. We'll start with file structure: in the root directory, there's one mimetype file and two folders--the OEBPS and the META-INF. Here's the mimetype file contents:
application/epub+zip
be sure not to have any return/line break characters in there.
In the META-INF folder, there's one file, the container.xml:
<?xml version="1.0"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
In the OEBPS folder, things get slightly more complex. First is the content.opf file:
<?xml version="1.0" encoding="UTF-8" ?>
<package xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" unique-identifier="db-id" version="3.0">
<metadata>
<dc:title id="t1">Title</dc:title>
<dc:identifier id="db-id">isbn</dc:identifier>
<meta property="dcterms:modified">2014-03-27T09:14:09Z</meta>
<dc:language>en</dc:language>
</metadata>
<manifest>
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml" />
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<item id="template_css" href="template.css" media-type="text/css" />
<item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" />
</manifest>
<spine toc="ncx">
<itemref idref="hello" />
</spine>
</package>
Then comes the toc.xhtml file:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>toc.xhtml</title>
<link href="template.css" rel="stylesheet" type="text/css" />
</head>
<body>
<nav id="toc" epub:type="toc">
<h1 class="frontmatter">Table of Contents</h1>
<ol class="contents">
<li><a href="1_hello.xhtml">Hello</a></li>
</ol>
</nav>
</body>
</html>
And finally we have the content of the ebook itself, in this case 1_hello.xhtml:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>1_hello.xhtml</title>
<link href="template.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
As a bonus, there's a toc.ncx file. This is not required to be valid, but it's required if you want the book to have a working Table of Contents on epub 2.0.1 devices (which is pretty much all of them):
<?xml version="1.0" encoding="UTF-8" ?>
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">
<head>
<meta name="dtb:uid" content="isbn"/>
<meta name="dtb:depth" content="1"/>
</head>
<docTitle>
<text></text>
</docTitle>
<navMap>
<navPoint id="hello" playOrder="1">
<navLabel><text>cover</text></navLabel>
<content src="1_hello.xhtml" />
</navPoint>
</navMap>
</ncx>
And there's also the template.css in there, which is just a CSS stylesheet. In this case, it looks like this:
h1 {
text-align: center;
}
And that's it! For more complex stuff, there are a number of free epub 3 samples available at code.google.com/p/epub-samples/.
Free books android app tbrJar TBR JAR Read Free books online gutenberg
More posts by @Phylliss

: Is it a good idea to minify code when coding ePubs? I typically minify my .css file because it's something I am used to when developing websites, but I have seen some people actually minify

: LibreOffice uses the international ISO/IEC standard OpenDocument file format as its native format to save documents for all of its applications (as do its OpenOffice.org cousins Apache OpenOffice