CSS page-break-after Property

Thuộc tính page-break-after trong CSS dùng để thêm ngắt trang sau phần tử chỉ định. Tương tự page-break-before, page-break-after, và page-break-inside đều quan trọng. Chúng giúp xác định tài liệu kết quả khi in sẽ như thế nào.

Lưu ý: Thuộc tính page-break-after không dùng được trên phần tử định vị tuyệt đối hoặc <div> rỗng.

Cú pháp:

page-break-after: auto|always|avoid|left|right|initial|inherit;

Giá trị mặc định: Giá trị mặc định của thuộc tính này là auto.

Giá trị thuộc tính:

  • auto: Giá trị này dùng để chỉ một dấu ngắt trang tự động.
page-break-after:auto;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: auto
    </title>
</head>
<body>
    <p style= "page-break-after:auto;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
  Text credits: https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • always: Khi dùng giá trị này, ngắt trang luôn được chèn sau hộp phần tử chỉ định.
page-break-after:always;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: always
    </title>
</head>
<body>
    <p style= "page-break-after:always;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <p style= "page-break-after:always;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    Text credits : https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • avoid: Khi dùng giá trị này, ngắt trang sẽ được tránh nếu có thể.
page-break-after:avoid;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: avoid
    </title>
</head>
<body>
    <p style= "page-break-after:avoid;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <p>
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    Text credits :https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • left: Khi dùng giá trị này, ngắt trang được chèn để trang tiếp theo là trang bên trái.
page-break-after:left;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: left
    </title>
</head>
<body>
    <p style= "page-break-after:left;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <p>
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    Text credits :https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • right: Khi dùng giá trị này, ngắt trang được chèn để trang tiếp theo là trang bên phải.
page-break-after:right;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: right
    </title>
</head>
<body>
    <p style= "page-break-after:right;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <p>
               The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    Text credits :https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • initial : Nếu giá trị này được dùng, thuộc tính sẽ được đặt về mặc định.
page-break-after:initial;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        page-break-after: initial
    </title>
</head>
<body>
    <p style= "page-break-after:initial;">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <p>
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    Text credits :https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    
  • inherit : Thuộc tính được kế thừa từ phần tử cha.
page-break-after:inherit;
  • Ví dụ
HTML
<!DOCTYPE html>
<html>
<head>
    <title>css_page_break_after</title>
    <style>
        p {
            page-break-after:always;
        }
        
        div{
            page-break-after:default;
        }
        
        #c1{
            page-break-after:left;
        }
        
        #c2{
            page-break-after:inherit;
        }
    </style>
</head>
<body>
    <p>
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p>
    <div>
        <p id="c2">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </div>
    <p id="c1">
        The oldest classical Greek and Latin 
        writing had little or no space between
        words and could be written in boustrophedon
        (alternating directions). Over time, text
        direction (left to right) became standardized,
        and word dividers and terminal punctuation 
        became common. The first way to divide sentences
        into groups was the original paragraphos, 
        similar to an underscore at the beginning of
        the new group.[2] The Greek paragraphos 
        evolved into the pilcrow, which in English 
        manuscripts in the Middle Ages can be seen 
        inserted inline between sentences. The hedera 
        leaf (e.g. ?) has also been used in the same way.
    </p> 
    Text credits :https://en.wikipedia.org/wiki/Paragraph
</body>
</html>                    

Lưu ý: Cách tốt nhất để xem kết quả của thuộc tính page-break-after là xem trước khi in trang web. Hãy tạo code tương tự trên trình soạn thảo văn bản như notepad++ rồi chọn xem trước khi in. Hãy thử để hiểu rõ hơn về thuộc tính này.

Trình duyệt được hỗ trợ: Dưới đây là danh sách các trình duyệt hỗ trợ thuộc tính page-break-after:

  • Google Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Opera 7+
  • Safari 1.2+

Last Updated : 21/07/2025