CSS orphans Property
The CSS orphans property specifies the minimum number of lines that must remain at the bottom of a page, column, or other fragment when a block of text is split.
It is used in paginated and fragmented layouts to prevent a paragraph from leaving too few lines before a break. The property works alongside widows, which controls the minimum number of lines appearing after a break.
orphans Syntax
The orphans property accepts a positive integer specifying the minimum number of lines required before a fragmentation break.
Basic Syntax
selector {
orphans: 3;
}
Default Value
p {
orphans: 2;
}
Require Three Lines
p {
orphans: 3;
}
Require Four Lines
p {
orphans: 4;
}
Print-Specific Declaration
@media print {
p {
orphans: 3;
}
}
CSS-Wide Keywords
p {
orphans: initial;
}
p {
orphans: inherit;
}
p {
orphans: unset;
}
p {
orphans: revert;
}
p {
orphans: revert-layer;
}
The initial value is 2. The property is inherited, so descendants normally use their parent's computed value unless another declaration overrides it.
Property Values
| Value | Description |
|---|---|
<integer> |
A positive whole number specifying the minimum number of lines before a break. |
initial |
Resets the property to 2. |
inherit |
Uses the computed value of the parent element. |
unset |
Inherits the parent's computed value because the property is inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | 2 |
| Inherited | Yes |
| Applies to | Block containers |
| Computed value | Specified integer |
| Animation type | Discrete |
| Primary use | Controlling line breaks in fragmented layouts |
Valid Values
p {
orphans: 1;
}
p {
orphans: 2;
}
p {
orphans: 5;
}
Each declaration uses a valid positive integer. A value of 1 permits a single line before a break.
Invalid Values
p {
orphans: 0;
}
p {
orphans: -2;
}
p {
orphans: 2.5;
}
p {
orphans: 50%;
}
Zero, negative numbers, decimals, and percentages are invalid because the property requires a positive integer.
How It Works
When a paragraph spans a page or column boundary, the browser determines where the lines can be divided.
The orphans property establishes the minimum number of lines that should remain in the earlier fragment.
Without a Larger Minimum
p {
orphans: 2;
}
A paragraph may be split after two lines, provided other fragmentation requirements are also satisfied.
With a Larger Minimum
p {
orphans: 4;
}
The browser attempts to keep at least four lines together before the break.
Example Line Distribution
Consider a paragraph containing eight lines that needs to span two pages.
| Declaration | Possible Distribution |
|---|---|
orphans: 2 |
2 lines on the first page, 6 on the next |
orphans: 3 |
3 lines on the first page, 5 on the next |
orphans: 4 |
4 lines on each page |
These are possible distributions, not guaranteed results. Available space and other break rules determine the actual placement.
When There Is Not Enough Space
If the remaining page or column space cannot accommodate the required lines, the browser may move more of the paragraph to the next fragment.
When fragmentation constraints cannot all be satisfied, the browser may relax some requirements to complete the layout.
Default Behavior
The initial value of orphans is 2, which helps prevent a paragraph from ending a page or column with only one line.
Initial Value
p {
orphans: 2;
}
Inherited Value
article {
orphans: 3;
}
Descendant block containers inherit the value unless a more specific declaration changes it.
Overriding Inheritance
article {
orphans: 3;
}
article p.special {
orphans: 2;
}
The special paragraph uses a minimum of two lines instead of the inherited value of three.
Important Consideration
The default value does not guarantee identical printed results across browsers. Pagination and column fragmentation can differ between rendering engines.
Minimum Line Requirements
Increasing the orphans value makes it harder for a browser to split a paragraph near its beginning.
Two-Line Minimum
p {
orphans: 2;
}
At least two lines should remain before a break.
Three-Line Minimum
p {
orphans: 3;
}
At least three lines should remain before a break.
Five-Line Minimum
p {
orphans: 5;
}
At least five lines should remain before a break, when the layout permits.
Short Paragraphs
If a paragraph has fewer lines than the requested minimum, the browser cannot satisfy that minimum by splitting the paragraph. It may keep the paragraph together or relax fragmentation constraints when necessary.
Choosing a Value
Values of 2 or 3 are common starting points. Larger values may improve the appearance of some documents but can also introduce additional whitespace or unexpected breaks.
orphans vs. widows
The orphans and widows properties work together to control the minimum number of lines on opposite sides of a fragmentation break.
| Property | Controls |
|---|---|
orphans |
Minimum lines remaining before the break, at the bottom of the earlier page or column |
widows |
Minimum lines appearing after the break, at the top of the following page or column |
Using Both Properties
p {
orphans: 3;
widows: 3;
}
This requests at least three lines on each side of a break when a paragraph is divided.
Example with Eight Lines
For an eight-line paragraph, a split of four lines on each page satisfies both declarations.
A split of two lines on the first page and six on the next would not satisfy orphans: 3.
A split of six lines on the first page and two on the next would not satisfy widows: 3.
Important Consideration
Both properties influence where breaks are allowed. They do not directly specify an exact line number at which a break must occur.
Using orphans with Page Breaks
Page breaks occur when content flows from one printed page to another. The orphans property helps control how paragraphs are divided at these boundaries.
Basic Printed Paragraphs
@media print {
p {
orphans: 3;
widows: 3;
}
}
The browser attempts to keep at least three lines of each split paragraph on both sides of a page break.
Long Articles
@media print {
article p {
orphans: 3;
widows: 2;
}
}
This requests at least three lines before a page break and two lines after it.
Preventing Breaks Inside Short Sections
@media print {
.short-section {
break-inside: avoid;
}
}
Unlike orphans, break-inside: avoid requests that the browser avoid splitting the entire section.
Important Consideration
Use orphans to control line distribution within paragraphs. Use break properties when you need to control where larger sections begin or end.
Using orphans with Columns
The orphans property is also relevant when text is fragmented across CSS columns.
Two-Column Layout
.article-columns {
columns: 2;
column-gap: 24px;
}
.article-columns p {
orphans: 3;
widows: 3;
}
When a paragraph is split between columns, the browser attempts to respect the minimum line counts.
Three-Column Layout
.article-columns {
column-count: 3;
column-gap: 20px;
}
.article-columns p {
orphans: 2;
}
The property requests at least two lines before a column break.
Column Height Constraints
.article-columns {
columns: 2;
height: 260px;
}
.article-columns p {
orphans: 4;
widows: 3;
}
A limited column height can make the requested minimums harder to satisfy. The browser may move content or relax constraints depending on the available space.
Important Consideration
Support for widow and orphan control in multi-column layouts may vary. Test the actual layout in the browsers you intend to support.
Related Break Properties
Several CSS properties work alongside orphans to influence fragmentation.
break-before
h2 {
break-before: page;
}
Requests a page break before each matching heading.
break-after
h2 {
break-after: avoid;
}
Requests that the browser avoid placing a break immediately after the heading.
break-inside
.content-box {
break-inside: avoid;
}
Requests that the browser avoid breaking inside the element.
Combining Break Rules
@media print {
h2 {
break-after: avoid;
}
p {
orphans: 3;
widows: 3;
}
.example-box {
break-inside: avoid;
}
}
These declarations help keep headings with following content, prevent isolated paragraph lines, and avoid splitting example boxes.
Important Consideration
Fragmentation rules can conflict. Forced breaks and available space may take precedence over preferred line counts.
Print Stylesheets
Print stylesheets are a practical place to define orphans because printed pages have clear fragmentation boundaries.
Basic Print Rules
@media print {
body {
font-size: 11pt;
line-height: 1.5;
}
p {
orphans: 3;
widows: 3;
}
}
Document-Specific Rules
@media print {
.document-content {
orphans: 3;
widows: 3;
}
.document-content h2 {
break-after: avoid;
}
}
The minimum line counts are inherited by descendant block containers, while headings request that the following content remain nearby.
Printing Long Documentation
@media print {
.tutorial-content p {
orphans: 3;
widows: 3;
}
.tutorial-content pre,
.tutorial-content table {
break-inside: avoid;
}
}
This combination is useful for printed HTML and CSS tutorials, where paragraphs, code examples, and tables should remain readable.
Important Consideration
Use your browser's print preview to inspect the actual results. Changes to paper size, margins, fonts, and line height can affect where paragraphs break.
orphans Example
This example applies orphans: 3 and widows: 3 to a multi-paragraph article intended for printing.
HTML Example
<article class="print-article">
<h2>Understanding CSS Layout</h2>
<p>CSS layout determines how elements are arranged within a document. Different layout methods provide different ways to control alignment, spacing, and positioning.</p>
<p>Flexbox arranges items along a main axis and supports flexible sizing. CSS Grid provides row and column tracks for more complex layouts. Both methods can adapt to different viewport sizes.</p>
<p>When documents are printed, content may extend across multiple pages. Fragmentation properties help control where page breaks occur and how text is distributed around those breaks.</p>
</article>
CSS Example
.print-article {
max-width: 700px;
margin: 0 auto;
line-height: 1.6;
}
.print-article p {
orphans: 3;
widows: 3;
}
@media print {
.print-article h2 {
break-after: avoid;
}
}
Understanding CSS Layout
CSS layout determines how elements are arranged within a document. Different layout methods provide different ways to control alignment, spacing, and positioning.
Flexbox arranges items along a main axis and supports flexible sizing. CSS Grid provides row and column tracks for more complex layouts. Both methods can adapt to different viewport sizes.
When documents are printed, content may extend across multiple pages. Fragmentation properties help control where page breaks occur and how text is distributed around those breaks.
Note: The effect of orphans is not normally visible in a continuous web page. Use your browser's print preview to observe how the paragraph lines are distributed when a page break occurs.
Additional Column Example
The following example applies the property to paragraphs in a two-column layout.
<div class="column-article">
<p>CSS provides several methods for arranging content. Flexbox is useful for one-dimensional layouts, while Grid provides more control over rows and columns.</p>
<p>Multi-column layouts divide text into separate columns. When a paragraph crosses a column boundary, fragmentation rules can influence where the text is divided.</p>
<p>The orphans and widows properties specify minimum line counts before and after a break. Their purpose is to reduce isolated lines in fragmented content.</p>
</div>
.column-article {
columns: 2;
column-gap: 24px;
line-height: 1.6;
}
.column-article p {
orphans: 3;
widows: 3;
}
CSS provides several methods for arranging content. Flexbox is useful for one-dimensional layouts, while Grid provides more control over rows and columns.
Multi-column layouts divide text into separate columns. When a paragraph crosses a column boundary, fragmentation rules can influence where the text is divided.
The orphans and widows properties specify minimum line counts before and after a break. Their purpose is to reduce isolated lines in fragmented content.
The browser attempts to respect the minimum line counts when paragraphs cross column boundaries. Actual results depend on the browser, available space, and column dimensions.
Common Mistakes
Confusing orphans with widows
orphans controls lines before a break. widows controls lines after a break.
Using Zero or Negative Values
p {
orphans: 0;
}
The declaration is invalid because the value must be a positive integer.
Using Decimal Values
p {
orphans: 2.5;
}
The property requires a whole number.
Expecting Visible Changes on a Normal Web Page
The property affects fragmentation. It does not change the appearance of an ordinary paragraph that is not split across pages or columns.
Expecting an Exact Break Position
The property specifies a minimum line count, not an exact line at which the browser must break.
Assuming All Browsers Behave Identically
Browser support and fragmentation behavior can differ, especially in multi-column layouts.
Using Very Large Values
Large minimums may cause unwanted whitespace or make fragmentation constraints difficult to satisfy.
Ignoring Other Break Properties
Forced page breaks, break-inside, and other fragmentation rules may influence the final layout.
Forgetting to Test Print Output
Always inspect the document in print preview because paper size, margins, and font settings can change line distribution.
Important Considerations
Keep the following points in mind when using orphans:
- The property specifies the minimum number of lines before a fragmentation break.
- Its initial value is
2. - The property is inherited.
- It applies to block containers.
- It accepts positive integer values.
- Zero, negative numbers, decimals, and percentages are invalid.
- It is primarily useful for printed pages and multi-column layouts.
- It does not control ordinary line wrapping within an unfragmented paragraph.
- It does not specify an exact break position.
- The
widowsproperty controls the minimum lines after a break. - Both properties can be used together.
- The browser considers available space when choosing break positions.
- Fragmentation requirements may be relaxed when they cannot all be satisfied.
- Large values may create additional whitespace.
- The property can be declared inside
@media print. - It can be combined with
break-before,break-after, andbreak-inside. - Browser behavior may differ between printed pages and CSS columns.
- Print preview is useful for testing the final appearance.
- Changes to fonts, line height, and page dimensions can affect fragmentation.
- Use realistic content when testing line distribution.
Browser Support
The CSS orphans property has limited availability across browsers and fragmentation contexts. It is not considered Baseline - Widely available.
Support varies depending on the browser and whether the content is being printed or divided into columns. Some browsers may recognize the property without consistently enforcing its line-count requirements.
For current compatibility information, visit Can I Use? and search for orphans.
Test the property using actual print previews or fragmented layouts rather than relying only on whether the declaration is accepted by the browser.
Specifications
The orphans property is defined in CSS Fragmentation Module Level 3.
CSS Fragmentation Module Level 3: Widows and Orphans
The specification defines how minimum line-count requirements influence breaks within block containers.
For additional documentation and examples, consult MDN Web Docs.
