HTML DOM Style widows Property

## JavaScript Reference

Overview

## JavaScript Objects

JS Array JS Boolean JS Date JS Math JS Number JS String JS RegExp JS Global

## Browser Objects

Window Navigator Screen History Location

## HTML DOM Objects

DOM Document DOM Elements DOM Attributes DOM Events

## HTML Objects

DOM Anchor DOM Area DOM Base DOM Body DOM Button DOM Form DOM Frame/IFrame DOM Frameset DOM Image DOM Input Button DOM Input Checkbox DOM Input File DOM Input Hidden DOM Input Password DOM Input Radio DOM Input Reset DOM Input Submit DOM Input Text DOM Link DOM Meta DOM Object DOM Option DOM Select DOM Style DOM Table DOM td / th DOM tr DOM Textarea

# Style widows Property

Style Object

## Definition and Usage

The widows property sets or returns the minimum number of lines for an element that must be visible at the top of a page (for printing or print preview).

The widows property only affects block-level elements.

Tip: widows:5 means that at least 5 lines must be visible below the page break.

Tip: See the orphans property to set or return the minimum number of lines for an element that must be visible at the bottom of a page.

## Syntax

Set the widows property:

Object.style.widows="number|inherit"

Return the widows property:

Object.style.widows

Value | Description
--- | ---
number | An integer that specifies the minimum number of visible lines. The default value is 2
inherit | The value of the widows property is inherited from parent element

## Browser Support

The widows property is only supported in Opera.

## Example

Change the widows and check print or print preview:

<html>
<head>
<script>
function ChangeWidows()
{
document.getElementById("p1").style.widows=document.getElementById("widows").value;
}
</script>
<style>
.othercontent
{
width:400px;
border-top:19cm solid #c3c3c3;
}
@page
{
/* set size of printed page */
size:21cm 27cm;
margin-top:2cm;
}
@media print
{
.widows
{
widows:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="widows" value="2">
<button onclick="ChangeWidows();">Change widows</button>
<p style="font-size:120%" id="p1">
Change widows and see the 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 class="othercontent">
</body>
</html>
Try it yourself »

Style Object

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE