CSS Cleanup removes common publisher, conversion, and device-specific stylesheet cruft from EPUB CSS files. It can process the current CSS file or all stylesheet files in the book.
Use the toolbar menu to choose whether to clean only the current CSS file or every stylesheet in the book. Whole-book cleanup is useful after conversion, but review the diff before accepting broad changes.
@font-face rules removes complete block-form font declarations from CSS. Text resembling @font-face inside comments, strings, declaration values, or malformed non-block at-rules is left alone.
font-family declarations by preserving generic families such as serif, sans-serif, and monospace while removing specific named fonts.
@font-face rules and are no longer referenced by remaining CSS or CSS-bearing XHTML, HTML, SVG, or XML resources.
If a font-family declaration lists only named fonts and no generic family, the whole declaration is removed rather than left empty. The text then falls back to the reader's default, which is usually the intended result, but it is a larger change than it may appear in the diff.
Only font files stored inside the book are candidates for deletion. Fonts loaded from a web address, or embedded directly in the stylesheet as data, are left in place.
Some EPUBs can contain custom CSS declarations that have no meaning for most ebook software. Use this to remove Adobe and vendor-specific declarations.
-adobe- or adobe-.
-webkit-, -moz-, -ms-, and -o-. The final declaration in a rule is removed even when its optional trailing semicolon is omitted.
-epub-. It is off by default because older EPUB 3 content can depend on these properties.
Explicit colors are often irrelevant on grayscale e-ink devices and may reduce contrast. The color options can remove explicit text and background colors while preserving behavioral or theme-friendly values.
color declarations.
background-color declarations.
The following values are preserved: inherit, currentColor, transparent, initial, unset, revert, and CSS variables such as var(--text-color). Related properties such as border-color are not removed by these options.
The custom property option removes declarations whose property names match a comma-separated list. The default list is line-height, font-variant-*, but the option is disabled by default.
Simple * wildcards are supported, for example font-*, page-break-*, and -epub-*. This removes declarations only; empty selectors can be removed afterward with Remove empty CSS rules after cleanup.
CSS Cleanup can convert selected print-oriented units to em values:
cm to em
mm to em
pt to em
These conversions are useful for CSS created from print layouts. They should still be reviewed, especially when measurements are used for layout rather than text spacing.
The conversion applies one fixed ratio per unit and rounds the result, rather than working out what em represents in each individual rule. It produces a sensible starting value, not an exact visual match, so margins and indents are worth checking after conversion.
After other cleanup operations, selectors may become empty. This option removes rules with no remaining declarations. It is useful after vendor-property or color cleanup.
Comments are left alone, including a comment sitting immediately before an empty rule, and a rule whose only remaining content is a comment. Licence and copyright notices in a stylesheet therefore survive.
A few things are never treated as active stylesheet content:
/* comment */, even where it looks like a rule or a declaration.
url() path, or a content value containing braces.
@charset and @import, which have no block to empty.
@font-face block, which is kept intact rather than partially removed.
For a converted or publisher EPUB, this order usually gives the cleanest result:
@font-face rules and named font families, with font-file deletion enabled.
line-height and font-variant-*.
All of these can be selected in a single run; the order above simply reflects how their effects build on each other.
CSS cleanup edits stylesheets directly. The tool creates a savepoint before processing and can show Calibre's diff afterward. Review both changed CSS files and any deleted font files before publication — a deleted font is the one change the diff viewer will not show you.