CSS calc()26 Mar 2025 | 3 min read It is an inbuilt CSS function which allows us to perform calculations. It can be used to calculate length, percentage, time, number, integer frequency, or angle. It uses the four simple arithmetic operators add (+), multiply (*), subtract (-), and divide (/). It is a powerful CSS concept because it allows us to mix any units, such as percentage and pixel. SyntaxValuesThis CSS function takes a single parameter expression, and the result of this mathematical expression will be used as a value. It can be any simple expression using the four arithmetic operators (+, -, *, /). The expression is mandatory to define. Important points
Example1- simple exampleIn this example, we are using the calc() function to define the width and height of the div element. There is the subtraction in the expression of calc() function with same units. The result of the expression will be treated as the value of the property, so, the value of width will be 75% and the value of height will be 275px. In the above example, we can directly mention the values of height and width. Although the expression in the above example has the same units, what happens when the units are different, then it will be hard to write the values directly. Now, we will see another demonstration in which we use mixed units. Example2- use of mix unitsLet's see another example in which we will use nested calc() function. Example3- nested calc() functionNext TopicCSS Clip |
CSS Clip-path CSS is short for Cascading Style Sheets. It's a language used to describe the display of documents written in markup languages such as HTML or XM. In the fast-changing world of web design, a never-ending issue is how to attract people and hold. Their...
9 min read
CSS Cubic-bezier() Function It is an inbuilt function in CSS that defines a Cubic Bezier curve. The Bezier curve is the mathematically defined curve used in 2D graphical applications such as (inkspace, adobe illustrator, etc.). This CSS function is the transition timing function, which is used...
5 min read
CSS Sticky The CSS position property sets the position for an HTML element. It is also used to place an item behind another element and is useful for the scripted animation effect. The "position: sticky;" is used to position the element based on the user's scroll position. This...
8 min read
This CSS property generates dynamic content. It can be used with the pseudo-elements ::before and ::after. This CSS property is fully supported in all browsers and used to insert the generated content on a web page. It replaces the element with the generated value. Syntax content: normal |...
5 min read
CSS outline is just like CSS border property. It facilitates you to draw an extra border around an element to get visual attention. It is as easy as to apply as a border. See this example: <!DOCTYPE html> <html> <style type="text/css"> .box { background-color:...
3 min read
How can a Triangle be Made in CSS? Triangles are a fundamental geometric form that may be used in various web design projects. Triangles may be made in CSS by employing a few straightforward methods. This tutorial will discover two methods for making triangles in CSS. Making Triangles...
4 min read
This CSS property allows us to change the case of the text. It is used to control the text capitalization. This CSS property can be used to make the appearance of text in all-lowercase or all-uppercase or can convert the first character of each word...
4 min read
The appearance of components on a webpage can be softened by using CSS to create rounded borders. Rounded borders offer a feeling of aesthetics and might enhance the visual attractiveness of the entire design. I'll go over all the different attributes and values you may use...
17 min read
It is hard to achieve consistency and cross-browser compatibility in web development. Tools like Normalize.css can be used. Normalize.css is small yet allows developers to create consistent and uniform styles across browsers. We have discussed essential details about Normalize.css in this article, including what it is,...
5 min read
The foundation of web design is Cascading Style Sheets (CSS), which gives developers control over the organisation and appearance of online pages. The placement of items on a webpage is one of the numerous functionalities it provides. Both "absolute" and "relative" positioning techniques are important in...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India