danfickle / danfickle/openhtmltopdf

Orphan html elements

Open
#481 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Hi,
I have a dynamic document which has some subheadings and variable length content below. In some cases, I get a heading placed at the end of one page, while the content starts in the next one. I tried to use `orphans` property, but during my tests I found it only works within the same tag.

So, how can I achieve this?

This is a small example to reproduce it, based on your annotated example. The desired effect would move "Title" to a new page, if there's no room for "Line 1" as well in the same page.

```html
.no-orphans {
widows: 0;
orphans: 2;
}


Title


Line 1


Line 2


Line 3


Line 4


Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

Line 11


```

NOTE: This is a small repro based on the example, but the real scenario replaces all the `

`'s content with `

`'s that contain images, text... And the amount of these is dynamically generated, so it's not easy to enclose the first one with the title in the same container to include a `no-break-inside` property, without including some non-desired and custom logic in the template.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.