Skip to content

H2 should not page-break-before #782

@DannyBen

Description

@DannyBen

This new (?) CSS is too opinionated in how H2s are used throughout the document.

@media print {
  .retype-markdown h2 {
    page-break-before: always;
  }
}

Even the Retype site itself does not benefit from this setting.

Just the first example I tried:
https://retype.com/guides/key-setup/

yields this (first 3 pages):

Image

This CSS should be removed in my opinion, and if there are any style customizations exposed in the Settings, it could be opt-in there.


For the time being, I am solving it with this include file (which also disables the unsolicited centering of the H1).

<!-- src/_includes/head.html -->
<style>
  @media print {
    /* Stop H1 from being centered */
    .retype-markdown h1 {
      text-align: start !important; /* follows document direction */
    }

    /* Stop H2 from starting a new page */
    .retype-markdown h2 {
      break-before: avoid-page !important;   /* modern */
      page-break-before: avoid !important;   /* legacy */
    }

    /* keep the heading with the first block after it */
    .retype-markdown h2 + * {
      break-inside: avoid !important;        /* modern */
      page-break-inside: avoid !important;   /* legacy */
    }
  }
</style>

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions