concept

typed-arithmetic — CSS reference

Typed calculations track dimensions. Dividing like dimensions produces a number, which can then be multiplied by a length. A final result with squared length cannot be assigned to width. Earlier implementations restrict division to numeric denominators, so use a conventional declaration before typed arithmetic. Intermediate type algebra and the property grammar are distinct checks.

Formal Syntax & Structure

css syntaxcss
calc(120px / 30px * 10px)

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS math lab</title><style>body {margin:0} .sample {height:12px;background:#006050}.parent {width:300px} .sample {width:40px;margin-bottom:4px} #a {width: calc(120px / 30px * 10px)} #b {width: calc(1in / 24px * 10px)}</style><body><div class="parent"><div id="a" class="sample"></div><div id="b" class="sample"></div></div></body></html>
CSS Reference