← All Quizzes
What does the CSS calc() function do?
Explanation
The CSS calc() function performs mathematical calculations (addition, subtraction, multiplication, division) with mixed units. For example, width: calc(100% - 40px) or font-size: calc(1rem + 2vw). This enables flexible, responsive layouts without JavaScript. calc() is especially useful for combining relative and absolute units, adjusting for fixed elements (like subtracting a sidebar width), and creating fluid typography. Spaces are required around + and - operators.