concept
unit-compatibility — CSS reference
Compatible dimensions can use different units: 1in is 96 CSS pixels. Addition and subtraction require compatible types, not identical unit strings. A length-percentage sum is permitted when the property defines how percentages resolve. Bare zero is not automatically a length inside math.
Formal Syntax & Structure
css syntaxcss
calc(1in + 4px)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(1in + 4px)} #b {width: calc(25% + 5px)}</style><body><div class="parent"><div id="a" class="sample"></div><div id="b" class="sample"></div></div></body></html>