In this section · Styling

Edit styles and HTML for a zone

Inspect and edit the CSS applied to any zone with a live preview, fix parent and reading order so a box renders as one unit, and edit a zone's HTML directly.

Each zone in the ePUB takes its look from a style in the document's stylesheet or your company stylesheet. From the HTML preview you can see which style a zone uses, change its CSS with a live preview, and decide whether a change applies to that zone only or to every zone that uses the style. When a box or heading still renders wrongly, the cause is often its structure, so this article also covers fixing parent and reading order, and editing a zone's HTML.

Before you start

Clean up the extracted styles and map your company styles first, so that most zones already use the right style. See Clean up styles and map company styles.

Open the styles pane and inspect a zone's style

  1. In the HTML Preview header, click the palette button (Show the styles pane). The Styles pane opens on the right, listing the styles you can apply.
  2. Make sure style names are shown beside the zones. If they aren't, click the tag button next to it (Show each zone's style name beside it). Each zone then shows its HTML tag and style name in the margin, for example h4 h4-xl-2.

The HTML preview with each zone's tag and style name in the margin, and the Styles pane open on the right

  1. Click a zone's style name in the margin. The Styles editor opens with the CSS applied to that zone.

The top of the editor shows the Style name, whether it is a document or company style, and how many zones use it. Below are the formatting buttons and the Properties list, one row per CSS property. Drag the editor by its header if it covers what you want to see.

You can also open the editor from the zone's toolbar on the PDF side, with Edit style.

Edit a style's CSS

  1. Change a property in the Properties list. For a colour, click the swatch to open the colour picker, or type the value. To add a property that isn't listed, use Add property… and type to search, for example margin, colour or border.
  2. Edited rows are marked with a dot. If a text colour no longer has enough contrast, the editor shows the ratio and a Fix to button with the closest colour that passes.
  3. Click Preview to see the change on the page before you save. Nothing is saved while you preview, and Cancel puts the page back.
  4. Under Apply to, choose where the change goes:
    • This zone only: the edit applies to the zone you opened.
    • Set for all N zones using "style": the style itself changes, and every zone that uses it follows.

The Styles editor for h4-xl-2 with an edited background colour, a contrast warning with a Fix to button, and Apply to set to This zone only

  1. Click the button at the bottom right. Its label says what it does, for example Save to this zone or Set for all 24 zones using "h4-xl". When only this zone uses the style, the button reads Save into the style "…" instead.

Apply to set to Set for all 24 zones using h4-xl, after removing a property from the style

To start over, click Discard edits above the properties list.

Remove or replace a zone's style

  1. Open the zone's style in the Styles editor.
  2. Open the Style dropdown. To remove the class, choose None. To replace it, choose another style. The list groups styles under Closest to this zone, Document styles and Company stylesheet. In most cases, replace the style with one of your company styles rather than removing it.
  3. Under Apply to, choose This zone only, or apply the change to every zone that uses the old style, for example Remove "h4-xl-2" from all 22 zones.

The Style dropdown set to None, with the choice between This zone only and Remove h4-xl-2 from all 22 zones

  1. Click the button at the bottom right to save.

Bring a heading into its box

Sometimes a box's heading is captured outside the box, so the ePUB shows the heading and the box as two separate blocks. Styling can't fix this. Fix the structure first, then style the box and heading.

  1. Open the Properties tab in the left panel, which lists the page's zones, and look at the box's zones. Here the box is a Section holding three paragraphs, while its heading WORK IT OUT sits in a different section above it.

The zone list with Heading (H6) WORK IT OUT inside one section, and the box's paragraphs inside a separate section below

  1. If the heading is wrapped in an extra section that doesn't belong, select that section and click Unwrap in its toolbar (Shift + U). The section is removed and its children stay on the page.

A section selected in the zone list, with Unwrap in the zone toolbar above the page

  1. Select the heading. In Parent Zone, choose the box's section, for example [19] SEC. The heading moves into the section, after its last child.
  2. In Reading Order, enter the number that puts the heading before the box's first paragraph, and click Save.

The heading now inside Section 19, with Parent Zone set to 19 SEC and Reading Order set to 20, above the box's paragraphs

Style the box and its heading

With the heading inside the box, style each one separately so they render as one unit.

  1. Click the box's style name in the margin to open its style.
  2. Adjust the properties, such as its padding, and click Preview to check the result on the page. Edit the values until it looks right, then save it.

The Styles editor in preview for bg-gainsboro-padded-4, with the padding edited and the box previewed on the right

  1. Click the heading's style name and open its style.
  2. Adjust its margins, preview the result, and click Save to this zone.

The heading's style h6-left-6 with edited left and right margins, previewed so the heading sits flush with the box

To match a colour from the page, click the swatch and use the eyedropper in the colour picker to sample it from the PDF.

Change a company style on one zone

The same editor opens on zones that use a company style. These are marked company.

  1. Click the zone's style name and edit the property, for example a paragraph's margin-left.
  2. Click Save to this zone. The change applies to this zone only. The option to set it for all zones is unavailable, because a company style is edited in the company stylesheet, not here.

The Styles editor for the company style U01_spacem-g1, with margin-left edited and only Save to this zone available

In the margin, an asterisk after a style name means the zone has its own formatting on top of its style. In the Styles pane, double-click a style to apply it without that formatting.

Apply a different style from the styles pane

  1. Select the zone.
  2. Type in Filter styles… at the top of the Styles pane. The list includes the document's styles and, under Company stylesheet, your company styles.
  3. Click a style to apply it. The preview updates and the zone's style name changes in the margin. The current style has a tick.

The Styles pane filtered to h5, with Default h5, h5 and h5-xl, next to the selected heading in the preview

Edit a zone's HTML

If a zone's content carries markup you don't want, such as leftover inline formatting in a footnote, edit its HTML directly.

  1. Hover over the zone's style name in the margin and click the code button (Edit HTML). You can also use Edit HTML in the zone's toolbar.

The Edit HTML code button beside a footnote's style name in the margin

  1. The Edit HTML window opens with the zone's content. Make your change, for example removing <span> tags that carry the PDF's colour and font. Auto Format indents the code to make it easier to read.

The Edit HTML: footnote window, with the footnote's text wrapped in two span tags

  1. Click Save Changes.

Check it worked

  • After you save a style change, a message confirms it, for example "bg-gainsboro-padded-5" updated on 1 zone, and the HTML preview shows the new look.
  • A box and its heading render together, with the heading at the top of the box.

The WORK IT OUT heading rendered at the top of its box in the HTML preview

Watch the video

Applying styles, part 9 of the PDFxt video series.