CSS Reference Property

widows k395a

The widows property is used to specify the minimum number of lines of a block-level container (such as a paragraph) that can/should be left at the top of a page or column, while the remaining lines are rendered on the previous page or column. 1h4k67

In typesetting and printed media, a widow is a paragraph-ending line or word that appears by itself at the top of a page/column, separated from the rest of the paragraph.

widows-example-pages
Image showing widows in a paged ebook.

In CSS, the widows (plural) property is used to specified just how many lines can be left at the top of a page/column.

The widows property is used to specify the number of widows allowed in a printed document to control page breaks in these documents. It is usually used in conjunction with the @media rule to specify the number of widows allowed at the start of a page.

@media print {
    p {
        widows: 2;
    }
}
                

For digital documents and web pages, it can be used in multi-column layouts to specify the number of lines that can be left at the start of a column.

.mag {
    column-width: 12em;
}

.mag p {
    widows: 2;
}
                
widows-example-columns
Image showing widows in a multi-column layout.

The widows property has a similar counterpart: the orphans property, which specifies the number of lines that fall at the end of the previous page/column, thus separated from the rest of the text. For example, in the same example of a multi-column layout above, there are two orphan lines, highlighted in red in the following image:

orphans-example-columns
Image showing orphans in a multi-column layout.

Refer to the orphans entry for more information.

If you specify a value for widows and one for orphans value and leave one line as a widow, even if the widows property specifies that the minimum number of widows should be two.

ing the difference between orphans and widows can be confusing sometimes. It is useful to use a mnemonic to help with that. The following sentences are two nice ways of ing the difference between orphans and widows:

  • “An orphan has no past; a widow has no future”.
  • “An orphan is left behind, whereas a widow must go on alone”.

Official Syntax 55184y

  • Syntax:

    widows: <integer> | inherit
  • Initial: 2
  • Applies To: block container elements
  • Animatable: no

Values 584j31

<integer>
An integer which specifies the number of lines that can be left at the beginning of a page or column. Negative values are not allowed.
inherit
Inherits the value of widows from the element’s parent.

Examples 3e5p5z

The following example specifies the number of widows for paragraphs in a multi-column layout:

.element {
    columns: 12em 3;
    column-gap: 3em;
    text-align: justify;
}

.element p {
    widows: 2;
}
                

Live Demo 2x4j2k

In the following demo, a paragraph that is split over two columns is highlighted in red. The value of the widows property is set to 2, which is the default value. Change the value of widows to see how it affects the number of lines from the paragraph that are left at the start of the column.

View this demo on the Codrops Playground

Browser k5t66

The widows property is ed in Chrome 25+, Opera 9.2+, Internet Explorer 8+ and on Android. It is not ed in Firefox, Safari and iOS.

Further Reading 4g1p1d

Written by

Last updated June 3, 2020 at 12:35 pm by Pedro Botelho

Do you have a suggestion, question or want to contribute? Submit an issue.