`rule-break` CSS property
The rule-break CSS shorthand 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.
The rule-break CSS shorthand 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.
CSS Demo: rule-break
```css interactive-example-choice rule-break: none;
```css interactive-example-choice
rule-break: normal;
```css interactive-example-choice rule-break: intersection;
```html interactive-example
<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>
```css interactive-example
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:
- column-rule-break
- row-rule-break
## Syntax
```css
/* Keyword values */
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.
```html hidden
Default rule breaks in grid
```css hidden
body {
font-family: sans-serif;
text-align: center;
}
h1 {
font-size: 1.25em;
}
h2 {
font-size: 1em;
}
:has(:checked) .grid {
rule-break: intersection;
}
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
rule: 5px solid red;
width: 100%;
}
.grid > div {
border: 1px solid green;
background-color: lime;
height: 30px;
}
@layer no-support {
@supports not (rule-break: intersection) {
body::before {
content: "Your browser doesn't support the rule-break property";
background-color: wheat;
display: block;
text-align: center;
padding: 1rem 0;
}
}
}
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.
```html hidden
Default rule breaks in flexbox
flex-direction: row
flex-direction: column
```css hidden
body {
font-family: sans-serif;
text-align: center;
}
h1 {
font-size: 1.25em;
}
h2 {
font-size: 1em;
}
:has(:checked) .flexbox {
rule-break: intersection;
}
article {
display: flex;
gap: 5vw;
rule: 1px solid black;
width: 100vw;
}
section {
flex-basis: 45vw;
}
.flexbox {
display: flex;
flex-flow: balance;
flex-line-count: 3;
gap: 20px;
rule: 5px solid red;
width: 100%;
}
.column {
flex-flow: column balance;
gap: 20px;
}
.flexbox > div {
border: 1px solid green;
background-color: lime;
flex: 1 1 auto;
height: 30px;
}
@layer no-support {
@supports not (rule-break: intersection) {
body::before {
content: "Your browser doesn't support the rule-break property";
background-color: wheat;
display: block;
text-align: center;
padding: 1rem 0;
}
}
}
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.
```html hidden
Default rule breaks in multi-col
- One fish
- Two fish
- Red fish
- Blue fish
- Black fish
- Blue fish
- Old fish
- New fish.
- This one has a little star.
- This one has a little car.
- Say! What a lot
- Of fish there are.
- Yes. Some are red.
- And some are blue.
- Some are old.
- And some are new.
- Some are sad.
- And some are glad.
- And some are very, very bad.
- Why are they
- Sad and glad and bad?
- I do not know.
- Go ask your dad.
```css hidden
body {
font-family: sans-serif;
text-align: center;
}
h1 {
font-size: 1.25em;
}
h2 {
font-size: 1em;
}
ol {
columns: 3 / 4em;
gap: 20px;
rule: 5px solid red;
}
li {
border: 1px solid green;
background-color: lime;
list-style-type: none;
margin-bottom: 5px;
}
:has([value="normal"]:checked) ol {
rule-break: normal;
}
:has([value="intersection"]:checked) ol {
rule-break: intersection;
}
:has([value="none"]:checked) ol {
rule-break: none;
}
label {
margin-right: 20px;
}
@layer no-support {
@supports not (rule-break: intersection) {
body::before {
content: "Your browser doesn't support the rule-break property";
background-color: wheat;
display: block;
text-align: center;
padding: 1rem 0;
}
}
}
Check the radio buttons for each value to see the value's effect.
Formal definition
Formal syntax
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>
```html hidden live-sample___basic
- 1
- 2
- 3
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
#### 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.
```css live-sample___basic
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.
css hidden live-sample___basic
ol {
place-items: center;
}
li {
text-align: center;
aspect-ratio: 1;
font-family: sans-serif;
line-height: 50px;
}
@layer no-support {
@supports not (rule-break: intersection) {
body::before {
content: "Your browser doesn't support the rule-break property";
background-color: wheat;
display: block;
text-align: center;
padding: 1rem 0;
}
}
}
Result
Specifications
Browser compatibility
See also
- rule-inset shorthand
- rule-overlap
- rule-visibility-items
- rule shorthand
- CSS gaps module