MDN self-hosted library · e01.org

`rule-overlap` CSS property

The rule-overlap CSS property specifies which rule is painted on top when column rules and row rules intersect.

no runnable cells css-property upstream source

The rule-overlap CSS property specifies which rule is painted on top when column rules and row rules intersect.

CSS Demo: rule-overlap

```css interactive-example-choice rule-overlap: row-over-column;


```css interactive-example-choice
rule-overlap: column-over-row;

```html interactive-example

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

```css interactive-example
#example-element {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-rule: solid thick orange;
  column-rule: solid thick purple;
}
#example-element i {
  padding: 5px;
}

Syntax

/* Keywords */
rule-overlap: row-over-column;
rule-overlap: column-over-row;

/* Global values */
rule-overlap: inherit;
rule-overlap: initial;
rule-overlap: revert;
rule-overlap: revert-layer;
rule-overlap: unset;

Values

This property is specified as a single keyword from the following list:

  • row-over-column
  • : Specifies that row rules are painted over column rules. This is the default value.
  • column-over-row
  • : Specifies that column rules are painted over row rules.

Formal definition

Formal syntax

Examples

Basic usage

In this example, we use the rule-overlap property to paint column rules on top of row rules.

HTML

We create a list of 75 items. Most of the HTML is hidden for brevity.

<ul>
  <li>1</li>
  <li>2</li>
  ...
  <li>74</li>
  <li>75</li>
</ul>

```html hidden live-sample___basic

  • 1
  • 2
  • 3
  • 4
  • 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
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75


#### CSS

We define the unordered list as a 10-column grid container using the grid-template-columns property. We set list-style-type to an empty string 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. Finally, we use the `rule-overlap` property to draw the column rules on top of the row rules.

```css live-sample___basic
ul {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  list-style-type: "";
  gap: 20px;

  row-rule: 20px solid palegoldenrod;
  column-rule: 20px solid olive;

  rule-overlap: column-over-row;
}

The rest of the CSS has been hidden for brevity.

css hidden live-sample___basic :has(:checked) ul { rule-overlap: row-over-column; } li { text-align: center; aspect-ratio: 1; line-height: 1.5em; } @layer no-support { @supports not (rule-overlap: row-over-column) { body::before { content: "Your browser doesn't support the rule-overlap property."; background-color: wheat; display: block; text-align: center; padding: 1rem 0; } } }

Result

Select the checkbox to toggle the value of the rule-overlap property.

Specifications

Browser compatibility

See also

  • rule-color
  • rule-width
  • rule-style
  • column-rule shorthand
  • row-rule shorthand
  • rule-visibility-items
  • CSS gaps module