Web Developer Interview Preparation calc( ) function September 26, 2018 Definition calc( ) is a feature that lets you perform mathematical calculations when you specifying CSS property values. Example width: calc(100% - 50px); Features Mix and match the units: you can subtract a pixel size from the percentage size Nest calc( ): you can nest calculations inside other calculations, and use it with CSS variablesGood browser compatibility: even down to IE 9 Example of nested calc() .foo { --widthA: 100px; --widthB: calc(var(--widthA) / 2); --widthC: calc(var(--widthB) / 2); width: var(--widthC); Note The + and – operators must be surrounded by whitespace.* and / operators do not require whitespace, but adding it for consistency is recommended. Reference How do you use calc() in CSS? [LINK] calc() MDN web docs [LINK] ]]> Previous calc( ) Newer CSS Variables Leave a Reply Cancel reply Your email address will not be published. Required fields are marked *Name * Email * Website Save my name, email, and website in this browser for the next time I comment. Comment