FictionBook describes the structure of a text, not its look: a reader decides how
titles, poems and quotations appear. The elements below are those of the FictionBook 2
schema; each must appear in the order given. All of them may carry
xml:lang, and most an id that links can point to.
body
| Child | Number | Content |
|---|---|---|
image | 0–1 | A picture shown before the text. |
title | 0–1 | The title of the body, often the book’s title and author. |
epigraph | Any | Epigraphs for the whole book. |
section | 1 or more | The text. |
The first body is the main text. A second, with
name="notes", holds footnotes and endnotes, one section with
an id per note; links in the text point to them with
type="note". Older files sometimes have further bodies (for example
name="comments"), which most readers accept and show after the text.
section
A chapter or other division. Sections nest to any depth.
| Child | Number | Content |
|---|---|---|
title | 0–1 | The heading. |
epigraph | Any | Epigraphs. |
image | 0–1 | A picture at the start. |
annotation | 0–1 | A summary of the section. |
either section | 1 or more | Subsections only, or… |
| or block content | 1 or more | …text: p, poem, subtitle, cite, empty-line, table, and, after the first block, image. |
A section holds either subsections or text, never both. Attributes: id,
xml:lang.
Block elements
| Element | Content | Attributes | Meaning |
|---|---|---|---|
p | text and inline elements | id, style, xml:lang | A paragraph. |
empty-line | empty | Extra vertical space, such as a scene break. | |
subtitle | as p | as p | A heading inside a section that does not start a new section. |
title | p and empty-line, any number | xml:lang | A heading of a body, section, poem or stanza; each line is a p. |
epigraph | p, poem, cite, empty-line, then text-author elements | id | An epigraph and who wrote it. |
annotation | p, poem, cite, subtitle, table, empty-line | id, xml:lang | A summary. |
cite | p, poem, empty-line, subtitle, table, then text-author elements | id, xml:lang | A quotation, such as a letter or document quoted in the text. |
text-author | as p | as p | The author of an epigraph, quotation or poem. |
poem | title (0–1), epigraph (any), subtitle or stanza (1 or more), text-author (any), date (0–1) | id, xml:lang | A poem or song. |
stanza | title (0–1), subtitle (0–1), v (1 or more) | xml:lang | A stanza. |
v | as p | as p | A line of verse. |
date | text | value, xml:lang | When the poem was written. |
image | empty | xlink:href, xlink:type, alt, title, id | A picture as a block of its own. |
Tables
| Element | Content | Attributes |
|---|---|---|
table | tr, 1 or more | id, style |
tr | th or td, 1 or more | align: left (default), right or center |
th, td | as p | id, style, colspan, rowspan, align (as above), valign: top (default), middle or bottom, xml:lang |
Inline elements
Paragraph-like elements (p, v, subtitle,
text-author, th, td) hold text mixed with:
| Element | Attributes | Meaning |
|---|---|---|
strong | Strong emphasis, usually bold. | |
emphasis | Emphasis, usually italic. | |
strikethrough | Struck-out text. | |
sub, sup | Subscript and superscript. | |
code | Computer code, in a fixed-width font. | |
style | name (required) | Text with a named style from a stylesheet. |
a | xlink:href (required), xlink:type, type | A link: #id inside the book, or a URL. With type="note" it is a note reference, and readers show the note’s section, usually as a pop-up. Links cannot nest. |
image | xlink:href, xlink:type, alt | A picture inside the line. |
The style elements nest inside one another and inside a.
binary
Images are stored inside the file, after the bodies, one binary element
each:
| Attribute | Status | Meaning |
|---|---|---|
id | Required | The name images refer to, such as cover.jpg. |
content-type | Required | The MIME type: image/jpeg or image/png, the two types readers support. |
The content is the file in Base64, usually broken into lines. An image element
refers to it with a local link: <image l:href="#cover.jpg"/>. Links
to files outside the book are allowed by the schema but rarely supported.
Example
<body>
<section id="ch1">
<title><p>Chapter One</p></title>
<epigraph>
<p>All happy families are alike.</p>
<text-author>Leo Tolstoy</text-author>
</epigraph>
<p>It was <emphasis>very</emphasis> cold.<a l:href="#n1" type="note">[1]</a></p>
<empty-line/>
<poem>
<stanza>
<v>The snow fell soft</v>
<v>on every roof.</v>
</stanza>
</poem>
</section>
</body>
<body name="notes">
<section id="n1"><title><p>1</p></title><p>Minus twenty degrees.</p></section>
</body>
<binary id="cover.jpg" content-type="image/jpeg">/9j/4AAQSkZJRgABAQ…</binary>