rule-break CSS property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The rule-break CSS property sets the behavior for breaking column and row rules into segments where rows and column gaps intersect, setting column-rule-break and row-rule-break to the same value.
Try it
rule-break: none;
rule-break: normal;
rule-break: intersection;
<section id="default-example">
<div id="example-element">
<i>A</i>
<i>B</i>
<i>C</i>
<i>D</i>
<i>E</i>
<i>F</i>
<i>G</i>
<i>H</i>
<i>I</i>
<i>J</i>
<i>K</i>
<i>L</i>
<i>M</i>
<i>N</i>
<i>O</i>
<i>P</i>
<i>Q</i>
<i>R</i>
<i>S</i>
<i>T</i>
<i>U</i>
<i>V</i>
<i>W</i>
<i>X</i>
<i>Y</i>
<i>Z</i>
</div>
</section>
#example-element {
display: grid;
grid-template-columns: repeat(7, 1fr);
row-rule: solid thick orange;
column-rule: solid thick purple;
gap: 10px;
}
#example-element i {
padding: 5px;
}
Constituent properties
This property is a shorthand for the following CSS properties:
Syntax
/* Keywords */
rule-break: none;
rule-break: normal;
rule-break: intersection;
/* Global values */
rule-break: inherit;
rule-break: initial;
rule-break: revert;
rule-break: revert-layer;
rule-break: unset;
Values
This property is specified as a single keyword from the following list:
none-
There are no breaks where row and column rules intersect; rather, a single continuous decoration is painted from one end of each gap to the other.
normal-
In flex and grid containers, behaves as
none. In multi-col,column-rule-breakbehaves asintersectionandrow-rule-breakbehaves asnone. This is the default value. intersection-
Rules always break when they intersect a gap, with rule segments starting and ending at container and gap edges.
Description
The rule-break property is used to set the behavior for breaking rules into segments when they cross gaps.
Gap decorations are painted within a gap as one or more gap decoration segments, with segments occurring between any two adjacent items. Depending on the container type, by default, these segments may either end at the edge of a gap, or the column and row rule may extend the entire height and width of the container.
When there is a break in a rule, by default, the segments start and end at the edge of the gaps. If the gap size is 0, the break may not be visible. The rule-break property determines if the break occurs. You can control the size of the break at the end of each segment with the rule-inset properties. When there are no breaks, and the line is continuous, rule-inset properties only affect the rule at the start and end edges of the container. When there are breaks, the rule-inset properties affect the start and end of every rule segment.
Whether a rule is by default composed of a single continuous segment or segments that break when intersecting gaps depends on the container type.
Grid containers
In grid containers, by default, rule segments continue through visible "cross" intersections. Setting rule-break: intersection will force the segments to break where they would otherwise cross.
Check the checkbox to set the rule-break to intersection, which makes the continuous rules break at every "cross" intersection.
Flex containers
In flexbox, when the flex-direction is row or row-reverse, the row rule is continuous, with the column segments starting and ending at the edge of the row gaps. When the flex-direction is column or column-reverse, the column rule is continuous, with the row segments starting and ending at the edge of the column gaps.
Note how, depending on the flex-direction, the column or row rules are continuous by default. If you set the rule-break to intersection, those continuous rules break at every intersection.
Multi-col containers
In multi-col containers, the default normal behavior differs between row rules and column rules. Column rule segments start and end when they intersect a row gap, behaving as column-rule-break: intersection, while row rules don't break when they intersect a column gap, behaving as row-rule-break: none.
Check the radio buttons for each value to see the value's effect.
Formal definition
Value not found in DB!Formal syntax
rule-break =
<'column-rule-break'>
<column-rule-break> =
none |
normal |
intersection
Examples
>Basic usage
In this example, we use the rule-break property to break each rule segment in a grid container so no rules intersect.
HTML
We create a list of 50 items. Most of the HTML is hidden for brevity.
<ul>
<li>1</li>
<li>2</li>
...
<li>49</li>
<li>50</li>
</ul>
CSS
We define the unordered list as a 8-column container, creating columns and rows with the grid-template-columns property and setting list-style-type to none to remove the bullets. We include a gap of 20px to provide enough room between the columns and rows to fit our 20px solid column and row rules. Last, we set the rule segments to break instead of intersect.
ul {
display: grid;
grid-template-columns: repeat(8, 1fr);
list-style-type: none;
gap: 20px;
row-rule: 20px solid palegoldenrod;
column-rule: 20px solid olive;
rule-break: intersection;
}
The rest of the CSS is hidden for brevity.
Result
Specifications
| Specification |
|---|
| CSS Gaps Module Level 1> # propdef-rule-break> |
Browser compatibility
See also
rule-insetshorthandrule-overlaprule-visibility-itemsruleshorthand- CSS gaps module