CSS | shape-image-threshold Property

The shape-image-threshold property is used to set the threshold of the alpha channel used to extract the shape when using an image for shape-outside.

Syntax:

shape-image-threshold: <alpha-value>

Property Values:



  • alpha-value: It is used to set the threshold for extracting the shape. The pixels which are greater than the threshold value would be considered for the shape. A decimal value from 0.0 to 1.0 can be used for setting the threshold from fully transparent to fully opaque. If the values are outside the range they are clamped to this range.

Below examples illustrate the shape-image-threshold Property:

Example 1: In this example, we will set the threshold to 0.5

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        CSS | shape-image-threshold
    </title>
    <style>
        .outline {
            shape-outside: linear-gradient(
                    to right, green, transparent);
          
            /* shape-image-threshold effect */
            shape-image-threshold: 0.4;
            background-image: linear-gradient(
                    to right, green, transparent);
            width: 300px;
            height: 130px;
            float: left;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
          
        <b>
            CSS | shape-image-threshold: 0.5;
        </b>
          
        <br><br>
    </center>
      
    <div class="outline"></div>
      
    <div class="container">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming 
        articles, quizzes and interview questions.
        The portal also has dedicated GATE preparation
        and competitive programming sections.
        <br><br
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and 
        explained computer science and programming
        articles, quizzes and interview questions.
        The portal also has dedicated GATE preparation
        and competitive programming sections.
    </div>
</body>
  
</html>

chevron_right


Output:

Example 2: In this example, we will set the threshold to 0.2

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        CSS | shape-image-threshold
    </title>
    <style>
        .outline {
            shape-outside: linear-gradient(20deg,
                rgb(77, 26, 103), transparent 80%,
                transparent);        
              
            /* shape-image-threshold effect */
            shape-image-threshold: 0.2;
            background-image: linear-gradient(
                to top, green, transparent);
            width: 300px;
            height: 125px;
            float: left;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
          
        <b>
            CSS | shape-image-threshold: 0.2;
        </b>
          
        <br><br>
    </center>
      
    <div class="outline"></div>
      
    <div class="container">
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and
        explained computer science and programming 
        articles, quizzes and interview questions.
        The portal also has dedicated GATE preparation
        and competitive programming sections.
        <br><br
        GeeksforGeeks is a computer science portal
        with a huge variety of well written and 
        explained computer science and programming
        articles, quizzes and interview questions.
        The portal also has dedicated GATE preparation
        and competitive programming sections.
    </div>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by shape-image-threshold property are listed below:

  • Google Chrome
  • Internet Explorer 9
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up

Maybe this silence is dangerous

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.