Style orphansProperty
Style Object
Definition and Usage
The orphans property sets or returns the minimum number of visible lines that an element must have at the bottom of a page (for print or print preview).
The orphans property only affects block-level elements.
Tip:orphans:5 means that at least 5 lines must be visible above the page break.
Tip:The widows property sets or returns the minimum number of visible lines that an element must have at the top of a page.
Syntax
Set the orphans property:
Object.style.orphans="number|inherit"
Return the orphans property:
Object.style.orphans
| Value | Description |
|---|---|
| number | An integer specifying the minimum number of visible lines. The default value is 2. |
| inherit | The value of the orphans property is inherited from the parent element. |
Browser Support
![]()
![]()
![]()
![]()
![]()
Only Opera supports the orphans property.
Example
Example
Change the orphans property for print or print preview:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function ChangeOrphans(){
document.getElementById("p1").style.orphans=document.getElementById("orphans").value;
}
</script>
<style>
.othercontent{
width:400px;
border-top:19cm solid #c3c3c3;
}
@page{
/* Set the print page size */
size:21cm 27cm;
margin-top:2cm;
}
@media print{
.orphans{
orphans:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="orphans" value="2"/>
<button onclick="ChangeOrphans();">Modify orphans property</button>
<p style="font-size:120%" id="p1">
Modify the orphans property for print or print preview.<br>
Line 2<br>
Line 3<br>
Line 4<br>
Line 5<br>
Line 6<br>
Line 7<br>
Line 8<br>
</p>
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function ChangeOrphans(){
document.getElementById("p1").style.orphans=document.getElementById("orphans").value;
}
</script>
<style>
.othercontent{
width:400px;
border-top:19cm solid #c3c3c3;
}
@page{
/* Set the print page size */
size:21cm 27cm;
margin-top:2cm;
}
@media print{
.orphans{
orphans:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="orphans" value="2"/>
<button onclick="ChangeOrphans();">Modify orphans property</button>
<p style="font-size:120%" id="p1">
Modify the orphans property for print or print preview.<br>
Line 2<br>
Line 3<br>
Line 4<br>
Line 5<br>
Line 6<br>
Line 7<br>
Line 8<br>
</p>
</div>
</body>
</html>
Try it yourself »
Style Object Other Extensions