Home  >  Article  >  Web Front-end  >  How to use css page-break-before attribute

How to use css page-break-before attribute

青灯夜游
青灯夜游Original
2019-05-29 14:47:462746browse

css page-break-before attribute is used to add a page break before the specified element. Note that this attribute cannot be used on absolutely positioned elements, and should also be avoided in tables, floating elements, and block elements with borders. All browsers support the page-break-before attribute.

How to use css page-break-before attribute

How to use the css page-break-before attribute?

The page-break-before property adds a page break before the specified element.

Note: Although you can use always to force page breaks, there is no guarantee that the insertion of page breaks will be avoided. The most the creator can do is ask the user agent to avoid inserting page breaks as much as possible. Applies to: non-floating block-level elements whose position value is relative or static.

Note: All major browsers support the page-break-before attribute. The property values ​​"left", "right", and "inherit" are not supported in any version of Internet Explorer (including IE8). Firefox, Chrome, and Safari do not support the attribute values ​​"avoid", "left", and "right".

css page-break-before attribute Example

Always insert a page break before the 4a249f0d628e2318394fd9b75b4636b1 element:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
@media print {
    h1 {page-break-before: always;}
}
</style>
</head>
<body>
....
</body>
</html>

The above is the detailed content of How to use css page-break-before attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn