Custom CSS and Custom Templates
When editing an Export Preset, you can fine-tune webpage element styles using Custom CSS, or add professional covers, tables of contents, and headers/footers to exported PDFs using Custom Templates.
Understanding the precedence and override rules between preset settings and global extension settings helps you organize layout rules more efficiently.
1. Custom CSS (Page Cleanups / Custom CSS)
Section titled “1. Custom CSS (Page Cleanups / Custom CSS)”In the Page Cleanups text box of the preset editor window, you can enter custom CSS rules dedicated to the current preset (such as hiding sidebars on specific websites, adjusting body font sizes, or forcing code blocks to wrap).
Relationship with Global Custom CSS: Additive & Cascading Precedence
Section titled “Relationship with Global Custom CSS: Additive & Cascading Precedence”The extension’s Main Settings page also provides a “Global Custom CSS” input box. Preset CSS and Global CSS do not mutually exclude each other (Global CSS remains active even when Preset CSS is configured); instead, they follow standard HTML stylesheet loading rules:
- Loading Order: When rendering a page, the extension loads Global Custom CSS first, followed by the current preset’s Custom CSS.
- Combined Effect: Rules from both sources are merged and applied to the current webpage. You can place universal site-wide ad-blocking and pop-up hiding rules in “Global CSS,” while keeping paper-size-specific adjustments in “Preset CSS.”
- Conflict Resolution (CSS Specificity): If Global CSS and Preset CSS define conflicting properties for the same webpage element, the final result is determined entirely by standard CSS cascading and selector specificity rules:
- Rules with higher selector specificity (or marked with
!important) take priority; - When selector specificity is identical, Preset CSS overrides Global CSS because it is loaded later.
- Rules with higher selector specificity (or marked with
2. Custom Templates & Override Global Settings
Section titled “2. Custom Templates & Override Global Settings”Custom templates add structured, publication-grade styling to exported PDFs, including:
- Single-Page Continuous Mode: Supports configuring a Frame Template to add a unified top title bar, bottom source watermark, or decorative border to long continuous pages.
- Multi-Page Paginated Mode: Supports configuring a complete book-style template suite, including a Cover Template, Table of Contents (with customizable TOC title), Body Frame Template (such as headers and page numbers), and Back Cover Template.
Relationship with Global Template Settings: Exclusive Override
Section titled “Relationship with Global Template Settings: Exclusive Override”Unlike the additive behavior of Custom CSS, template configuration uses an exclusive replacement mechanism. In the preset editor window, check the Override global settings box to enable preset-specific templates:
- Unchecked (Default): The current preset does not define separate templates and directly inherits the templates configured in the extension’s Global Settings.
- Checked (Override global settings): Template configurations in Global Settings are completely disabled (ignored) in favor of the templates specified within the current preset. Even if you leave a template slot blank inside the preset, it will not fall back to the global template.
💡 How to Write and Use Custom Templates? For template variable syntax, HTML/CSS structure guides, and preset template examples, see the upcoming Applying Template Styling section.