Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `rule`

The `rule` shorthand sets the same `column-rule` and `row-rule`; `4px solid red` expands width, style, and color for gap decorations on both axes.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<'column-rule'>

The rule shorthand sets the same column-rule and row-rule; 4px solid red expands width, style, and color for gap decorations on both axes.

The example applies rule:4px solid red to a 2×2 grid. Chromium returns identical row and column shorthands, while pixels show horizontal and vertical red separators without changing track dimensions.

Grammar: <'column-rule'>.

The shorthand resets omitted components; without a style other than none, no line is painted. Lists and repeat() can vary successive gaps in grid, flex, multicol, and grid-lanes, but this CSS Gaps Editor’s Draft feature needs @supports.

Examples

<!doctype html><meta charset="utf-8"><style>html,body{margin:0;background:white}#grid{display:grid;grid-template:20px 20px/40px 40px;gap:20px;width:100px;rule:4px solid red}</style><div id="grid"><i></i><i></i><i></i><i></i></div><pre id="result"></pre><script>const s=getComputedStyle(grid),v='4px solid rgb(255, 0, 0)';if(s.rule!==v||s.rowRule!==v||s.columnRule!==v)throw new Error('rule mismatch');result.textContent='rule='+s.rule+'; row='+s.rowRule+'; column='+s.columnRule;</script>

Result

rule=4px solid rgb(255, 0, 0); row=4px solid rgb(255, 0, 0); column=4px solid rgb(255, 0, 0)

The example applies `rule:4px solid red` to a 2×2 grid. Chromium returns identical row and column shorthands, while pixels show horizontal and vertical red separators without changing track dimensions.

Sources