concept
Custom css function — CSS reference
Author-defined CSS functions compute values using parameters and local declarations in a function rule. They differ from custom properties because the caller supplies arguments. Use a plain CSS fallback and avoid relying on an invalid returned value to revive an earlier declaration.
Formal Syntax & Structure
css syntaxcss
width: --double(30px);Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>custom-css-function</title><style>body{margin:8px;font:16px/20px sans-serif;color:black;background:white}@function --double(--x <length>) returns <length> { result:calc(var(--x)*2); } #a{width:20px;width:--double(30px);height:20px;background:blue}</style><body><p id="a">Example text</p></body></html>