calc() Function - HTML CSS CSS

HTML CSS examples for CSS:Function

Definition and Usage

The calc() function does calculation on the property value.

CSS Syntax

Value Require Description
expression Required. A mathematical expression. The operators can be used: + - * /

The following code shows how to Use calc() to calculate the width of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
#div1 {<!--  ww w .j a va 2 m-->
    position: absolute;
    left: 50px;
    width: calc(100% - 100px);
    border: 1px solid black;
    background-color: red;
    padding: 5px;
    text-align: center;

<div id="div1">Some text...</div>


Related Tutorials