function

Sibling count() — CSS reference

Returns the number of sibling elements including the subject. It is not restricted to siblings matching the current selector. Text nodes do not increase the element count. Use it to distribute a fixed quantity among siblings, with ordinary layout as a fallback.

Formal Syntax & Structure

css syntaxcss
width: calc(240px / sibling-count());

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>sibling-count()</title><style>body{margin:16px;font:16px/1.5 system-ui;background:white;color:#172033} .demo{background:#dbeafe;box-sizing:border-box} button,select{font:inherit}#list>div{width:calc(240px/sibling-count())}</style><body><div id="list"><div id="a" class="demo">A</div><div id="b" class="demo">B</div><div id="c" class="demo">C</div></div></body></html>
CSS Reference