Answers.Body: <p>In regards to my comments about Tom's ePub not validating there is an error in his <code>toc.xhtml</code> on line 13 and should be coded as <code>&lt;li&gt;&lt;a href="1_hello.xhtml"&gt;Hello&lt;/a&gt;&lt;/li&gt;</code> which will produce the error message from IDPF validator as:</p>
  
  <p><img src="https://i.sstatic.net/OUvQQ.jpg" alt="enter image description here"></p>
  
  <p>In regards to the version 3.0 ePub I disagree and believe it should be noted that when an ePub is built as ePub 3.0 format ONLY it will not validate other than 3.0 in epubcheck.  This can be achieved and tested in the terminal using <a href="https://github.com/IDPF/epubcheck/wiki/Running" rel="noreferrer">epubcheck command line</a> (which is a different question).  </p>
  
  <p>If the provided ePub is submitted and ran against epubcheck version 2.0 it will fail for the following:</p>
  
  <ul>
  <li><code>value of attribute "version" is invalid; must be equal to "2.0"</code></li>
  <li><code>attribute "property" not allowed here; expected attribute "content", "id", "name", "scheme" or "xml:lang"</code></li>
  <li><code>element "meta" missing required attributes "content" and "name"</code></li>
  <li><code>text not allowed here; expected the element end-tag</code></li>
  <li><code>attribute "properties" not allowed here; expected attribute "fallback", "fallback-style", "href", "media-type", "required-modules" or "required-namespace"</code></li>
  <li><code>element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")</code></li>
  <li><code>element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")</code></li>
  </ul>
  
  <p>That displayed my argument with the industry standard is that a <code>version 2.0</code> ePub CAN be built to support and function with devices that run <code>version 3.0</code> and it should be coded as such for quality and validation.</p>
  
  <p>Also, if we are talking about what the structure of ePubs are.  Using a OEBPS file structure was technically meant for ePub's in version 1.  Since it really doesn't matter what the file structure is as long as the <code>container.xml</code> points and finds a true <code>.opf</code> file I petition and build my ePubs like so:</p>
  
  <pre><code>META-INF
  -container.xml
  xhtml
  -toc.xhtml
  -.xhtml files
  css
  -stylesheet.css
  content.opf
  toc.ncx
  mimetype
  </code></pre>
  
  <p>I find it easier for maintenance and less annoying searching for a <code>.opf</code> or <code>.ncx</code> file in either <code>OEBPS</code>, <code>OPS</code>, <code>OPF</code>, etc. etc. file structures.</p>
  
  <p>Also Im a big fan of commenting my code and since it will not change the performance I code my manifest as such:</p>
  
  <pre><code>&lt;manifest&gt;
      &lt;!-- .ncx --&gt;
      &lt;item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" /&gt;
  
      &lt;!-- .xhtml --&gt;
      &lt;item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" /&gt;
      &lt;item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" /&gt;
  
      &lt;!-- .css --&gt;
      &lt;item id="css_file" href="stylesheet.css" media-type="text/css" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-01T17:15:35.683Z
Answers.Text: Thanks for catching that unclosed quote in the toc.xhtml; I've corrected the typo in my original answer and double-checked the file by copying and pasting; it validates just fine on the current version of epubcheck.
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-31T18:38:55.783Z
Answers.LastActivityDate: 2014-03-31T18:57:48.147Z
Answers.LastEditDate: 2014-03-31T18:57:48.147Z
Answers.UserDisplayName: DᴀʀᴛʜVᴀᴅᴇʀ
Answers.Body: <p>Here's an epub 3.0 file that validates with <a href="https://github.com/IDPF/epubcheck/releases">epubcheck 3.0.1</a> (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:</p>
  
  <pre><code>application/epub+zip
  </code></pre>
  
  <p>be sure not to have any return/line break characters in there.
  In the META-INF folder, there's one file, the container.xml:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"&gt;
    &lt;rootfiles&gt;
      &lt;rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/&gt;
    &lt;/rootfiles&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>In the OEBPS folder, things get slightly more complex. First is the content.opf file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;package xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" unique-identifier="db-id" version="3.0"&gt;
  
  &lt;metadata&gt;
      &lt;dc:title id="t1"&gt;Title&lt;/dc:title&gt;
      &lt;dc:identifier id="db-id"&gt;isbn&lt;/dc:identifier&gt;
      &lt;meta property="dcterms:modified"&gt;2014-03-27T09:14:09Z&lt;/meta&gt;
      &lt;dc:language&gt;en&lt;/dc:language&gt;
  &lt;/metadata&gt;
  
  &lt;manifest&gt;
      &lt;item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml" /&gt;
      &lt;item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" /&gt;
      &lt;item id="template_css" href="template.css" media-type="text/css" /&gt;
      &lt;item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" /&gt;
  &lt;/manifest&gt;
  
  &lt;spine toc="ncx"&gt;
      &lt;itemref idref="hello" /&gt;
  &lt;/spine&gt;
  
  &lt;/package&gt;
  </code></pre>
  
  <p>Then comes the toc.xhtml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"&gt;
  &lt;head&gt;
  &lt;title&gt;toc.xhtml&lt;/title&gt;
  &lt;link href="template.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;nav id="toc" epub:type="toc"&gt;
          &lt;h1 class="frontmatter"&gt;Table of Contents&lt;/h1&gt;
          &lt;ol class="contents"&gt;
                 &lt;li&gt;&lt;a href="1_hello.xhtml"&gt;Hello&lt;/a&gt;&lt;/li&gt;
          &lt;/ol&gt;
  
      &lt;/nav&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>And finally we have the content of the ebook itself, in this case 1_hello.xhtml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"&gt;
  &lt;head&gt;
  &lt;title&gt;1_hello.xhtml&lt;/title&gt;
  &lt;link href="template.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;h1&gt;Hello World!&lt;/h1&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/"&gt;
  
  &lt;head&gt;
      &lt;meta name="dtb:uid" content="isbn"/&gt;
      &lt;meta name="dtb:depth" content="1"/&gt;
  &lt;/head&gt;
  
  &lt;docTitle&gt;
      &lt;text&gt;&lt;/text&gt;
  &lt;/docTitle&gt;
  
  &lt;navMap&gt;
      &lt;navPoint id="hello" playOrder="1"&gt;
          &lt;navLabel&gt;&lt;text&gt;cover&lt;/text&gt;&lt;/navLabel&gt;
          &lt;content src="1_hello.xhtml" /&gt;
      &lt;/navPoint&gt;
  &lt;/navMap&gt;
  
  &lt;/ncx&gt;
  </code></pre>
  
  <p>And there's also the template.css in there, which is just a CSS stylesheet. In this case, it looks like this:</p>
  
  <pre><code>h1 {
    text-align: center;
  }
  </code></pre>
  
  <p>And that's it! For more complex stuff, there are a number of free epub 3 samples available at <a href="https://code.google.com/p/epub-samples/">https://code.google.com/p/epub-samples/</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:09:39.703Z
Answers.Text: I respect the level of effort you put into your answer but you do realize it isn't a valid ePub and you should provide more detail in case someone copies to produce from.
Answers.UserDisplayName: DᴀʀᴛʜVᴀᴅᴇʀ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:11:27.410Z
Answers.Text: Hmm; validates for me just fine. What errors are you seeing and what version of epubcheck are you using?
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:14:44.907Z
Answers.Text: The version.  Your ePub will not pass ePubcheck lvl 2.0 validation.  An ePub should be built to be valid across the board for legacy devices and at this time your ePub is only 3.0 valid and not 2.0 valid.
Answers.UserDisplayName: DᴀʀᴛʜVᴀᴅᴇʀ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:16:28.250Z
Answers.Text: You appear to have some misconceptions about how epub files work. This will open just fine on any legacy system because of the inclusion of the toc.ncx, as noted in my answer.
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:18:54.453Z
Answers.Text: No it's not a misconception.  If that ePub is ran through a 2.0 validator from some retailers it will not pass validation.  An ePub should be valid across the board and at this time yours is not.
Answers.UserDisplayName: DᴀʀᴛʜVᴀᴅᴇʀ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:22:27.427Z
Answers.Text: There is no such thing as an epub 2.0 validator. There is only one validator for epub. It validates epub 2 and 3. We've never had a retailer or distributor have problems in 2 years of producing epub 3
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:27:10.540Z
Answers.Text: ill provide an answer with clarity when I have some extra time.
Answers.UserDisplayName: DᴀʀᴛʜVᴀᴅᴇʀ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T01:59:36.443Z
Answers.Text: Sounds great! That's one of the things the Stack Exchange sites are best for.
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-28T12:43:41.720Z
Answers.Text: @Gramps Do these retailers require derivations from resp. additions to the standard? In that case, I would not support your "should be valid across the board" claim. This thinking led us to divergent technology in HTML 4 and consorts. If they don't adhere to the standard, nobody should support them. End of story.
Answers.UserDisplayName: Raphael
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-27T16:33:34.253Z
Answers.LastActivityDate: 2014-04-01T17:02:07.090Z
Answers.LastEditDate: 2014-04-01T17:02:07.090Z
Answers.UserDisplayName: Tom
Body: <p>I would like to create my own ePub documents from scratch without a tool so that I have full control over the final result.</p>
  
  <p>What is the absolute minimum set of required files to have a valid ePub file? Or, to put it in programming terms, what would an ePub "Hello, world." file look like?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-10T19:13:54.467Z
Comments.Text: I was looking for the same thing (minimal valid EPUBs) and decided to create my own: https://github.com/bmaupin/epub-samples I also found these repositories from IDPF to be incredibly helpful when it comes to additional features: https://github.com/IDPF/epub3-samples https://github.com/IDPF/epub-testsuite
Comments.UserDisplayName: bmaupin
Tags: <epub><creation><production>
Title: What is the minimum required content for a valid ePub?
UserDisplayName: Donald.McLean
ThreadText: # What is the minimum required content for a valid ePub?
  
  (Asked by: username_0 on 2014-03-27)
  
  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 the absolute minimum set of required files to have a valid ePub file? Or, to put it in programming terms, what would an ePub "Hello, world." file look like?
  
  **Tags:** epub, creation, production
  
  > **Comments:**
  > **username_1**: I was looking for the same thing (minimal valid EPUBs) and decided to create my own: https://github.com/username_1/epub-samples I also found these repositories from IDPF to be incredibly helpful when it comes to additional features: https://github.com/IDPF/epub3-samples https://github.com/IDPF/epub-testsuite  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2014-03-27. Score: 22 | Accepted answer
  
  Here's an epub 3.0 file that validates with [epubcheck 3.0.1](https://github.com/IDPF/epubcheck/releases) (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 <https://code.google.com/p/epub-samples/>.
  
  > **Comments:**
  > **username_2**: I respect the level of effort you put into your answer but you do realize it isn't a valid ePub and you should provide more detail in case someone copies to produce from.  
  > **username_3**: Hmm; validates for me just fine. What errors are you seeing and what version of epubcheck are you using?  
  > **username_2**: The version.  Your ePub will not pass ePubcheck lvl 2.0 validation.  An ePub should be built to be valid across the board for legacy devices and at this time your ePub is only 3.0 valid and not 2.0 valid.  
  > **username_3**: You appear to have some misconceptions about how epub files work. This will open just fine on any legacy system because of the inclusion of the toc.ncx, as noted in my answer.  
  > **username_2**: No it's not a misconception.  If that ePub is ran through a 2.0 validator from some retailers it will not pass validation.  An ePub should be valid across the board and at this time yours is not.  
  > **username_3**: There is no such thing as an epub 2.0 validator. There is only one validator for epub. It validates epub 2 and 3. We've never had a retailer or distributor have problems in 2 years of producing epub 3  
  > **username_2**: ill provide an answer with clarity when I have some extra time.  
  > **username_3**: Sounds great! That's one of the things the Stack Exchange sites are best for.  
  > **username_4**: @Gramps Do these retailers require derivations from resp. additions to the standard? In that case, I would not support your "should be valid across the board" claim. This thinking led us to divergent technology in HTML 4 and consorts. If they don't adhere to the standard, nobody should support them. End of story.  
  
  ---
  
  ### Answer by username_2 on 2014-03-31. Score: 6
  
  In regards to my comments about Tom's ePub not validating there is an error in his `toc.xhtml` on line 13 and should be coded as `<li><a href="1_hello.xhtml">Hello</a></li>` which will produce the error message from IDPF validator as:
  
  ![enter image description here](https://i.sstatic.net/OUvQQ.jpg)
  
  In regards to the version 3.0 ePub I disagree and believe it should be noted that when an ePub is built as ePub 3.0 format ONLY it will not validate other than 3.0 in epubcheck. This can be achieved and tested in the terminal using [epubcheck command line](https://github.com/IDPF/epubcheck/wiki/Running) (which is a different question).
  
  If the provided ePub is submitted and ran against epubcheck version 2.0 it will fail for the following:
  
  * `value of attribute "version" is invalid; must be equal to "2.0"`
  * `attribute "property" not allowed here; expected attribute "content", "id", "name", "scheme" or "xml:lang"`
  * `element "meta" missing required attributes "content" and "name"`
  * `text not allowed here; expected the element end-tag`
  * `attribute "properties" not allowed here; expected attribute "fallback", "fallback-style", "href", "media-type", "required-modules" or "required-namespace"`
  * `element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")`
  * `element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")`
  
  That displayed my argument with the industry standard is that a `version 2.0` ePub CAN be built to support and function with devices that run `version 3.0` and it should be coded as such for quality and validation.
  
  Also, if we are talking about what the structure of ePubs are. Using a OEBPS file structure was technically meant for ePub's in version 1. Since it really doesn't matter what the file structure is as long as the `container.xml` points and finds a true `.opf` file I petition and build my ePubs like so:
  
  ```
  META-INF
  -container.xml
  xhtml
  -toc.xhtml
  -.xhtml files
  css
  -stylesheet.css
  content.opf
  toc.ncx
  mimetype
  
  ```
  
  I find it easier for maintenance and less annoying searching for a `.opf` or `.ncx` file in either `OEBPS`, `OPS`, `OPF`, etc. etc. file structures.
  
  Also Im a big fan of commenting my code and since it will not change the performance I code my manifest as such:
  
  ```
  <manifest>
      <!-- .ncx -->
      <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
  
      <!-- .xhtml -->
      <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />
      <item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" />
  
      <!-- .css -->
      <item id="css_file" href="stylesheet.css" media-type="text/css" />
  </manifest>
  
  ```
  
  > **Comments:**
  > **username_3**: Thanks for catching that unclosed quote in the toc.xhtml; I've corrected the typo in my original answer and double-checked the file by copying and pasting; it validates just fine on the current version of epubcheck.  
  
  ---
  
  