- Home
- /
- CSS Maths Functions
CSS Tutorial
Introduction
CSS Properties
CSS Designing
CSS Advance Topics
CSS FAQs
- Home
- /
- CSS Maths Functions
CSS Maths Functions
CSS provides math functions that allow you to dynamically calculate values for properties like width, height, margin, padding, and more. These functions make layouts more flexible and responsive, especially when dealing with mixed units or adaptive designs.
calc() Function
The calc()
function lets you do basic math operations in your CSS. It supports +
, -
, *
, and /
.
selector {
property: value !important;
}
Subtracting from full width
This box uses calc(100% - 40px)
for width.

Explanation: This ensures that the box always adjusts to 100% of its parent container but leaves 40px for margin or other spacing.
max() Function
The max()
function chooses the larger of two values and uses that as the final value.
Minimum width protection
This box uses max(300px, 50%)
. It will always be at least 300px wide.
Use case: Ensures that the width never drops below 300px even on smaller screens.

min() Function
The min()
function picks the smaller of two values to assign.
Maximum width control
This box uses min(400px, 80%)
. It won't go over 400px wide.

Use case: Prevents elements from growing too large on wide screens.