Comments on: orphans https://css-tricks.com Tips, Tricks, and Techniques on using Cascading Style Sheets. Mon, 13 Jun 2022 15:15:34 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Scott https://css-tricks.com/almanac/properties/o/orphans/#comment-1608760 Thu, 25 May 2017 04:50:03 +0000 http://css-tricks.com/?page_id=14085#comment-1608760 It’s a year later, but I figured I’d answer Klappy’s question: on the heading, set page-break-after: avoid

<h2 style="page-break-after:avoid">Heading</h2>
<p>Text<br>Text<br>Text<br>Text<br>Text<br>Text<br>Text<br>Text</p>

The <h2> should always sit with the text.

]]>
By: James https://css-tricks.com/almanac/properties/o/orphans/#comment-1606595 Tue, 07 Feb 2017 15:51:57 +0000 http://css-tricks.com/?page_id=14085#comment-1606595 In reply to Christopher Mackay.

I realized I did not actually answer your question, but rather stated that your question was not relevant to this topic. So to answer your question, I do not know of a way to automatically (dynamically) handle that with a CSS-only solution. If the browser has determined that a line break is required that typically means there wasn’t enough room for that last word on the previous line. And if there is no room on the previous line, then what else would you do with that last word? If you think the best solution is to have a minimum number of words per line, then you would have to use javascript to determine that and fix it after the text is rendered, as well as whenever the viewport is resized.

]]>
By: James https://css-tricks.com/almanac/properties/o/orphans/#comment-1606594 Tue, 07 Feb 2017 15:35:38 +0000 http://css-tricks.com/?page_id=14085#comment-1606594 In reply to Christopher Mackay.

I know this is old, but I think ORyan misunderstood the context in which Christopher was asking his question and my answer is to clarify things for anyone coming after me that sees ORyan’s reply and assumes it will resolve Christopher’s issue. I think Christopher was referring to non-print media, but the article clearly states that it does not affect “screen” media except when used in combination with CSS columns. I believe Christopher was asking outside the context of print media because a single word on a new line at the end of a paragraph (while can look ugly and be frustrating at times) is a different problem than a single word that has a column (or page, in print media) all to itself, which is where the widows property would apply. But to answer your question, Chris’, the issue you asked about is not what this post is about. It is about print media (mostly) and preventing pages/columns from having too little text and the end (orphans) or beginning (widows).

]]>
By: Klappy https://css-tricks.com/almanac/properties/o/orphans/#comment-1601987 Sat, 04 Jun 2016 04:10:47 +0000 http://css-tricks.com/?page_id=14085#comment-1601987 In reply to Klappy.

I updated my CodePen example to show what I ended up attempting. I ended up wrapping the heading and the first paragraph with a div and used “break-inside: avoid;” to prevent it from wrapping. If anybody knows a better way, please share.

]]>
By: Klappy https://css-tricks.com/almanac/properties/o/orphans/#comment-1601986 Sat, 04 Jun 2016 03:46:19 +0000 http://css-tricks.com/?page_id=14085#comment-1601986 Is there a way to handle orphaned headings? In my use case I have a heading that needs to be grouped with the text. Using orphans and widows properties works with the text, but I have dangling headings that become orphans as the following text wraps to the next column. Is there a different way to handle it and ensure that the heading isn’t left by itself on the preceding column and the text continues on the next?

Example here (may have to resize browser window to see the issue):

]]>
By: ORyan https://css-tricks.com/almanac/properties/o/orphans/#comment-1595933 Fri, 17 Jul 2015 18:00:20 +0000 http://css-tricks.com/?page_id=14085#comment-1595933 In reply to Christopher Mackay.

What you are talking about is not an orphan. It’s called a widow and there is a property for that as well.

https://css-tricks.com/almanac/properties/w/widows/

]]>
By: Al https://css-tricks.com/almanac/properties/o/orphans/#comment-1207450 Wed, 26 Feb 2014 20:15:55 +0000 http://css-tricks.com/?page_id=14085#comment-1207450 I wish this wasn’t an image I like to manipulate after I research. But thank you for this was enlightening.

]]>
By: Serkan https://css-tricks.com/almanac/properties/o/orphans/#comment-1145804 Sun, 09 Feb 2014 22:22:48 +0000 http://css-tricks.com/?page_id=14085#comment-1145804 It’s a pity that safari and firefox do not support this!

]]>
By: Christopher Mackay https://css-tricks.com/almanac/properties/o/orphans/#comment-746102 Sun, 01 Dec 2013 21:38:15 +0000 http://css-tricks.com/?page_id=14085#comment-746102 What about the other case of orphans, where a single word is left on its own line at the bottom of a paragraph? This is most objectionable when it’s a short word, say, fewer than 6 letters.

There are plug-ins for WordPress to do this, but I don’t like burdening the server for what should be a minor presentational tweak.

]]>
By: Manoj https://css-tricks.com/almanac/properties/o/orphans/#comment-530134 Fri, 30 Aug 2013 13:28:32 +0000 http://css-tricks.com/?page_id=14085#comment-530134 Thanks for the clear explanation.

]]>