CSS box-decoration-break Property
February 10, 2021 12:37 pm IST
CSS box-decoration-break Property CSS box-decoration-break
property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.
Example <!DOCTYPE html>
<html lang ="en-US" >
<head >
<style >
span {
padding : 1px 5px ;
border-radius : 16px ;
font-size : 24px ;
line-height : 2 ;
border : 5px solid green ;
}
span :nth-child (3 ){
-webkit- box-decoration-break : slice ;
-moz- box-decoration-break : slice ;
box-decoration-break : slice ;
}
span :nth-child (5 ){
-webkit- box-decoration-break : clone ;
-moz- box-decoration-break : clone ;
box-decoration-break : clone ;
}
</style >
</head >
<body >
<h1 >CSS box-decoration-break property</h1 >
<h2 >box-decoration-break: slice;</h2 >
<span >This text<br >breaks<br >across multiple<br >lines</span >
<h2 >box-decoration-break: clone;</h2 >
<span >This text<br >breaks<br >across multiple<br >lines</span >
</body >
</html >
Syntax Using CSS element{
box-decoration-break: clone;
}
Using Javascript object.style.boxDecorationBreak="clone";
Animatable No, box-decoration-break property is not animatable. CSS Animatable Properties Reference.
Default Value Default value for CSS box-decoration-break property is slice .
Property Value The following table provides a list of values for CSS box-decoration-break
property.
Value Explanation slice The element is initially rendered as if its box were not fragmented, after which the rendering for this hypothetical box is sliced into pieces for each line/column/page. clone Each box fragment is rendered independently with the specified border, padding, and margin wrapping each fragment.
Using JavaScript In the following example, we will demonstrate how to change the CSS box-decoration-break
property of an element using JavaScript.
Example <!DOCTYPE html>
<html lang ="en-US" >
<head >
<style >
span {
padding : 1px 5px ;
border-radius : 16px ;
font-size : 24px ;
line-height : 2 ;
border : 5px solid green ;
-webkit- box-decoration-break : slice ;
-moz- box-decoration-break : slice ;
box-decoration-break : slice ;
}
button {
display : block ;
margin-top : 5px ;
}
</style >
</head >
<body >
<h1 >CSS box-decoration-break property</h1 >
<span >This text<br >breaks<br >across multiple<br >lines</span >
<button onclick ="myFunction" >Click Me</button >
<script >
var x = document .getElementsByTagName ("span" )[0 ];
function myFunction (){
x .style .boxDecorationBreak = "clone" ;
x .style .WebkitBoxDecorationBreak = "clone" ;
x .style .OBoxDecorationBreak = "clone" ;
}
</script >
</body >
</html >
Reminder Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in CSS .
Please do google search for:
Join Our Channel Join our telegram channel to get an instant update on depreciation and new features on HTML , CSS , JavaScript , jQuery , Node.js , PHP and Python .
This channel is primarily useful for Full Stack Web Developer.
Share this Page Meet the Author