Skip to content

HTML/ePub Style Reference

This is a technical reference for anyone writing or tweaking a Custom HTML or ePub Export Style in Atlas. It covers the CSS selectors Atlas emits for HTML and ePub output, the ePub package layout, and a set of tips and tricks for book-style formatting on the web and in eBook readers.

For PDF styles — which use a JSON configuration instead of CSS — see PDF Style Reference.

If you're just getting started with custom styles, read Custom Export Styles first.

Info

PDF export styles are a structured configuration, not a stylesheet. The CSS reference in this guide applies to HTML and ePub only. For PDF, use the PDF style editor (or import a .pdfstyle package) to control fonts, margins, headers, footers, and per-heading typography.

HTML and ePub CSS Reference

Atlas emits clean, semantic HTML from your markdown and links each chapter to the stylesheet from the selected Export Style. There are no bespoke wrapper elements for titles, authors, or chapters beyond a small number of layout hooks — so in general you style standard tags.

Selectors Atlas Emits

Selector What it targets
h1h6 Headings in the document. h1 is typically the chapter heading.
p Body paragraphs.
blockquote, blockquote p Blockquotes and their inner paragraphs.
ul, ol, li, li > p Unordered and ordered lists.
code Inline code.
pre, pre code Fenced code blocks.
a Links.
img Block-level images (figures).
img.inline Small images that flow inline with text. Atlas tags these automatically based on size.
hr Horizontal rules written directly in your markdown.
table, th, td Tables.
.chapter-break Wrapper <div> applied to the 2nd and later chapters in a continuous export. Use this to force page breaks or drop-cap openings for chapters after the first.
hr.atlas-doc-separator The horizontal rule Atlas inserts between documents in a continuous folder export. Carries a data-doc-index="N" attribute so you can target specific separators.
nav[epub\|type="toc"] ePub table-of-contents navigation (ePub only).

Properties Worth Knowing for ePub

ePub 3 readers honor a handful of pagination properties you can use to control how content breaks across pages:

.chapter-break     { page-break-before: always; }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
p                  { orphans: 2; widows: 2; }
pre, table, img    { page-break-inside: avoid; }

These are the defaults the built-in ePub styles use. You can override or extend them freely in a custom style.

What You Cannot Style with CSS

  • Book title and author — written to the ePub's content.opf metadata, not to chapter XHTML. Readers display them through their own library UI. If you want a visible title page inside the book, create a document at the top of your folder whose first h1 is the title and style that h1 specially (for example, via .chapter-break:first-of-type h1 logic) or via the book-title document.
  • ePub cover page — Atlas generates a fixed, minimal cover XHTML (body { margin: 0; text-align: center; } img { max-width: 100%; max-height: 100%; }). The cover image itself is the artwork; the surrounding page is intentionally unstyled.
  • Reader font preferences — most eReaders let users override fonts and sizes. Treat your style as a default, not a guarantee.

ePub Package Layout

When Atlas exports an ePub, it produces a standard ePub 3 package. Knowing the layout helps if you want to inspect, debug, or post-process a file.

mimetype                        (stored, uncompressed: "application/epub+zip")
META-INF/
  container.xml                 (points at OEBPS/content.opf)
OEBPS/
  content.opf                   (package manifest, spine, metadata)
  toc.xhtml                     (navigation document, <nav epub:type="toc">)
  styles/
    style.css                   (the selected Export Style)
  content/
    chapter-1.xhtml
    chapter-2.xhtml
    ...
    cover.xhtml                 (only if a cover image was selected)
  images/
    cover.[ext]                 (only if a cover image was selected)
    image-1.jpg
    image-2.png
    ...

Chapter XHTML Template

Every chapter file follows this shape:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:epub="http://www.idpf.org/2007/ops"
      lang="en" xml:lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>Chapter Title</title>
    <link rel="stylesheet" type="text/css" href="../styles/style.css"/>
</head>
<body>
    <div class="chapter-break">   <!-- only on chapters 2+ -->
        <!-- rendered markdown content -->
    </div>
</body>
</html>

The first chapter omits the .chapter-break wrapper so it opens cleanly; every subsequent chapter is wrapped, which is what makes .chapter-break { page-break-before: always; } work as a chapter-boundary hook.

Metadata in content.opf

<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:title>Your Book Title</dc:title>
    <dc:creator>Author Name</dc:creator>
    <dc:language>en</dc:language>
    <dc:identifier id="bookid">urn:uuid:...</dc:identifier>
    <meta property="dcterms:modified">2026-04-06T12:00:00Z</meta>
</metadata>
<nav epub:type="toc">
    <h1>Table of Contents</h1>
    <ol>
        <li><a href="content/chapter-1.xhtml">Chapter One</a></li>
        <li><a href="content/chapter-2.xhtml">Chapter Two</a></li>
    </ol>
</nav>

Atlas builds the TOC automatically from the documents in your folder when you export with One chapter per document selected. See Exporting an ePub for the chapter mode setting.

Tips and Tricks for Formatting Books

A few patterns that go a long way when you're styling long-form work.

Use h1 as Your Chapter Marker

Atlas treats the first h1 in a document as that chapter's heading, and the ePub TOC draws from it. Reserve h1 for chapter titles and use h2h6 for in-chapter sections. That alone makes the document outline, ePub navigation, and the Novel PDF style's running header behave correctly.

Force a New Page Between Chapters

In ePub, the simplest recipe:

.chapter-break { page-break-before: always; }
.chapter-break h1 {
    margin-top: 4em;
    text-align: center;
    font-weight: bold;
}

This gives every chapter after the first a clean page break and a centered heading with breathing room.

Set Paragraph Style Once

For prose, indented paragraphs without extra vertical space is the traditional book look:

p {
    text-indent: 1.25em;
    margin: 0;
}
p:first-of-type,
h1 + p, h2 + p, h3 + p {
    text-indent: 0;
}

The follow-up rule removes the indent from the first paragraph of a chapter or section — a small detail, but the one that separates "stylesheet" from "book design."

Mind Your Widows and Orphans

p { orphans: 2; widows: 2; }

Two lines of a paragraph never sit alone at the top or bottom of a page. The built-in ePub styles set this; keep it in any custom style you write.

Keep Figures and Code Blocks Intact

pre, table, img, blockquote {
    page-break-inside: avoid;
}

Readers handle these differently, but this is the right ask in nearly every case.

Distinguish Inline from Block Images

Atlas automatically tags small images with img.inline so they flow with text. Use that to style the two differently:

img          { display: block; margin: 1em auto; max-width: 100%; }
img.inline   { display: inline; vertical-align: middle; max-width: 2em; }

Test on More Than One Reader

ePub rendering varies. At minimum, spot-check your export in Apple Books (macOS and iOS) and a second reader like Calibre or Thorium. Custom fonts, drop caps, and decorative flourishes are the most likely things to render differently.

See Also