Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

rule-width — gap separator thickness

The rule-width shorthand gives row and column gap decorations the same thickness without changing the size of the gaps.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate; example verification in Chromium 152 is pending

Syntax

rule-width: <'column-rule-width'>;

rule-width sets column-rule-width and row-rule-width to the same value. It does not accept a separate pair of values for the two directions. Both longhands initially have medium and are not inherited.

Use a nonnegative length or thin, medium, thick; the grammar also includes comma-separated lists and repeat(). Percentages are invalid. Decoration thickness changes neither gap nor item layout. A visible separator also needs a style other than none or hidden.

This feature is defined in the CSS Gaps working draft. Do not assume support in a particular browser: the example requires local parsing and rendering checks.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>rule-width: gap separator thickness</title>
  <style>
    #grid {
      display: grid;
      grid-template: repeat(2, 50px) / repeat(2, 80px);
      width: max-content;
      gap: 20px;
      rule-style: solid;
      rule-color: black;
      rule-width: 4px;
    }
    #grid > div { background: #ddd; }
  </style>
</head>
<body>
  <div id="grid">
    <div>A</div><div>B</div><div>C</div><div>D</div>
  </div>
  <p id="status" role="status"></p>
  <script>
    const grid = document.getElementById('grid');
    const status = document.getElementById('status');
    const style = getComputedStyle(grid);
    const supported = CSS.supports('rule-width', '4px');
    let passed;
    if (supported) {
      const row = style.getPropertyValue('row-rule-width');
      const column = style.getPropertyValue('column-rule-width');
      status.textContent = `rule-width syntax supported. Computed row rule: ${row}; column rule: ${column}.`;
      passed = row === '4px' && column === '4px';
    } else {
      status.textContent = 'rule-width syntax unsupported.';
      passed = false;
    }
    console.log(`rule-width declaration check: ${passed ? 'PASS' : 'FAIL'}`);
    console.log(`Computed row and column gaps: ${style.rowGap} / ${style.columnGap}`);
  </script>
</body>
</html>

Result

rule-width declaration check: PASS
Computed row and column gaps: 20px / 20px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources