Recently I've started using the calc(...) method within CSS. I quickly learned that code such as: width: calc(100%-2)
will not work, though adding white-space before and after the -
operator will fix the problem and the calc method will function properly.
After doing a bit of research I found multiple blog posts reference that the white-space is required and many have even pointed to the specification (CSS3 8.1.1) which states:
In addition, whitespace is required on both sides of the + and - operators. (The * and / operaters can be used without whitespace around them.)
Now, clearly, the spec tells us that these operators must be wrapped in white-space, but why? I've read further within the spec (through sections 8.1.2-4) and if it's explained in these additional portions, I'm not understanding the reasoning.
In simple terms, could someone explain why it was specified that calc(100% - 1)
or even calc(100%/2)
is acceptable syntax but not calc(100%-1)
?