×

CSS Functions

CSS functions are used for different CSS properties. Every front-end developer should have knowledge of all CSS functions. It makes the coding easier.

FunctionsExplanation
attr().It returns the value of an attribute of the selected element, which is quite significant.
calc().Allows you to specifically perform calculations to determine CSS property values, kind of contrary to popular belief. Calculate any mathematical functions.
conic - gradient().It creates a conic gradient subtly.
counter().Returns the very current value of the named counter in a major way.
cubic - bezier().Explains a cubic Bezier curve, kind of contrary to popular belief.
hsl().Explains colors using the Hue-Saturation-Lightness model (HSL) subtly. This function describes the level of colors by using hsl.
hsla().Explains colors using the Hue-Saturation-Lightness-Alpha model (HSLA) in a major way.
linear - gradient().This function works as an inbuilt function in CSS which is utilized to set the linear gradient as background picture.
max().Uses the largest value, from a comma-separated list of values, as the property value. Set the max of nos. Given.
min().This function works in css is utilized to extract the mini value from a bunch of comma-separated values. 
repeating - conic - gradient().Repeats a conic gradient, which generally is quite significant.
repeating - linear - gradient().Repeats a linear gradient, definitely contrary to popular belief. 
repeating - radial - gradient().Subtly repeats a radial gradient.  
rgb().Explains colors using the Red-Green-Blue model (RGB) subtly. Describes the level of color.
rgba().Explains colors using the Red-Green-Blue-Alpha model (RGBA). Describes the levels of color.
var().Inserts the value of a custom property, which is fairly significant.
url()Function is used to set list-style, image, cursor, mask, mask-image, background-image, content, list-style-image.
blur()Blur effect is applied by this function.
brightness()The brightness is adjust by this function.
opacity()Opacity of the element is set .
not()Apply the style to image (img) element not having .no-p class.

Some functions for the most part are described/explained using small code(syntax) are as follows :

background: url(“image.png/image.jpg”)

height: calc(90%-50px)

      -    var( <custom-property-name> , <declaration-value>? )

      -    color: rgb(0,0,0)

color: rgba(0,0,0,1)

color: hsl(0,0,0)

.body{
          filter: blur(100px);
              }

.h2{
       filter: brightness(40%);
    }

img {
      filter: opacity(40%);
   }

img:not(.no-p){
           padding: 0;  }

Some examples with its code and output:

1. calc() function-

            code is as follows:

<!DOCTYPE html>
           <html>
           <head>
           <style>
             #div1 
              { position: absolute;
                  left: 45px;
                  width: calc(50% - 50px);
                  border: 1px solid black;
                  background-color: lightgray;
                  padding: 4px;
                  text-align: center;
               }
               </style>
               </head>                       
    <body>
      <h1> The calc() function  in CSS </h1>
      <p> This is the short paragraph which creates div , <br>
             with a 40px gap between both sides of 
             the div and edge of window: </p> 
      <div id=”div1”>write something text here..</div>
      </body>
      </html>

Output 1 for the above calc() code is:

CSS Functions

2. rgb() function-

code is as follows

<!DOCTYPE html>
                 <html>
                 <head>  
<style>
#p1 { background-color: rgb(128 , 0 , 128) ; } 
#p2 { background-color: rgb (255 , 255, 0) ; }
#p3 { background-color: rgb (255, 0 , 255 ) ; }
#p4 { background-color: rgb (192,192 ,192 ) ; }
#p5 { background-color: rgb (0 , 255, 0) ; }
#p6 { background-color: rgb (0 , 128, 128) ; }
#p7 { background-color: rgb ( 255, 127 , 80  ) ; }
</style>
</head>
<body>
<h1>The rgb() Function in CSS </h1>
<p> Different rgb colors : </p> 
< p id=”p1”> Purple </p>
< p id=”p2”> Yellow </p>
< p id=”p3”> Blue  </p>
< p id=”p4”> Silver </p>
< p id=”p5”> Lime </p>
< p id=”p6”> Teal </p>
< p id=”p7”> Coral </p>
</body>
</html>

Output for the above rgb() code is:

CSS Functions

3. rgba() function

code is as follows :

<!DOCTYPE html>
<html>
<head>  
<style>
#p1 { background-color: rgba(198, 0 , 198,0.3 ) ; } 
#p2 { background-color: rgba(20, 214, 20, 0.836); }
#p3 { background-color: rgba(0,0,255,0.3 ); }
#p4 { background-color: rgba(192,192,192,0.3 ) ; }
#p5 { background-color: rgba(255, 255, 0, 0.884) ; }
#p6 { background-color: rgba(240, 84, 12, 0.795) ; }
#p7 { background-color: rgba(255, 0, 0, 0.473) ; }
</style>
</head>
<body>
<h1>The rgb() Function in CSS </h1>
<p> Different rgb colors : </p> 
<p id="p1"> Purple </p>
<p id="p2"> Green </p>
<p id="p3"> Blue </p>
<p id="p4"> Light blue </p>
<p id="p5"> Yellow </p>
<p id="p6"> Orange </p>
<p id="p7"> Pink </p>




</body>
</html>

Output for the above rgba() code is:

CSS Functions

4. blur() function

code is as follows :

<!DOCTYPE html> 
<html> 
<head> 
    <title>The blur() Function in CSS </title> 
 <style>
        h1 {
            color: pink ;
             }
  body {
            text-align:center;
        }
        .blur_effect {
            filter: blur(4px);
        }
</style>
</head> 
<body> 
    <h1>Flower photograph </h1> 
    <h2>CSS blur() function</h2>
   <img class="blur_effect" src = "flower.png"
        alt="Flower image"> 
</body> 
</html>

Output for the above blur() code is:

CSS Functions

Related Topics

What is CSS used for

What is CSS used for? CSS stands for Cascading Style Sheet. CSS is a stylesheet language for web pages. It specifies how a document created in a markup language looks and...

4 minutes read.

CSS Transition

CSS Transition The transitions in CSS are influenced, included to modify the component from one design to another, without the use of the JavaScript or Flash. We should describe two of the...

2 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

How to edit CSS in WordPress

Developing a new website or blog is a difficult undertaking. We want to create something that the consumers will adore, but we might not want the setting to take months and...

7 minutes read.

Difference between CSS Grid and CSS Flexbox

The way that information is arranged on a website reveals a lot about you or your company. Organizational abilities are just as important as having the right materials. The design...

3 minutes read.

Untitled Reusable Block

  ...

1 minute read.

CSS Clip

CSS Clip The Clip property in CSS describes the element’s visible area. It applies over the elements which are absolutely positioned (position: absolute ;). Generally, it is used when an image...

2 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

CSS Text-Transform Property

Text-Transform in CSS The text-transform property permits us to alter the text case. It controls the capitalization of the text. This property is employed to design the text appearance in every...

3 minutes read.

CSS Form

You can create attractive HTML form by using CSS. Style input Fields The Input Field width properties are used to determine the width of the input field. Let us see an example of CSS style...

2 minutes read.

CSS :root selector

CSS :root selector This CSS pseudo-class matches any document’s root element. It chooses the parent of the highest-level inside the document DOM or tree. An element of <html> is always a...

2 minutes read.

CSS Important

CSS Important: CSS !important property is used to provide more importance, as compared to other CSS properties. The meaning of this property is “This is important.” This property enables CSS...

2 minutes read.

How to resize an image in CSS

How to resize an image in CSS? The resize image attribute is used in responsive web design to resize images to fit within the div container automatically. The resize image attribute...

3 minutes read.

CSS Filter

CSS Filter CSS filter is used to apply visual effects on the images, text, and other factors of the webpage. This filter property in CSS allows us to admit the effects like...

7 minutes read.

CSS Position

CSS Position: The position property in CSS is applied to set the position of the elements. It can be used to position the backside of an element. It is also...

3 minutes read.

CSS Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The...

8 minutes read.

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with...

3 minutes read.

Css Text Orientation

Introduction: The text-orientation property of CSS is used to specify the orientation of the text characters in the line of content. This property applies only with the vertical writing-mode and not...

4 minutes read.

CSS Float

CSS Float: The float property of CSS is the positioning property. This property is applied to elements to push them either to left or right. It permits for wrapping facility...

4 minutes read.