mask-type
Quick Summary for mask-type
The mask-type CSS property sets whether an SVG <mask> element is used as a luminance or an alpha mask. It applies to the <mask> element itself.
Code Usage for mask-type

<pre class="brush: css notranslate"><code><span class="token comment">/ Keyword values /</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> luminance<span class="token punctuation">;</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> alpha<span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> revert<span class="token punctuation">;</span> <span class="token property">mask-type</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for mask-type

mask-type

The mask-type CSS property sets whether an SVG <mask> element is used as a luminance or an alpha mask. It applies to the <mask> element itself.

/* Keyword values */ mask-type: luminance; mask-type: alpha;  /* Global values */ mask-type: inherit; mask-type: initial; mask-type: revert; mask-type: unset; 

This property may be overridden by the mask-mode property, which has the same effect but applies to the element where the mask is used. Alpha masks will generally be faster to render.

Syntax

The mask-type property is specified as one of the keyword values listed below.

Values

luminance

Is a keyword indicating that the associated mask image is a luminance mask, i.e., that its relative luminance values must be used when applying it.

alpha

Is a keyword indicating that the associated mask image is an alpha mask, i.e., that its alpha channel values must be used when applying it.

Formal definition

Initial valueluminance
Applies to<mask> elements
Inheritedno
Computed valueas specified
Animation typediscrete

Formal syntax

luminance | alpha

Examples

Setting an alpha mask

HTML
<div class="redsquare"></div> <svg version="1.1" xmlns="http://www.w3.org/2000/svg"     xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">   <defs>     <mask id="m" maskContentUnits="objectBoundingBox"       style="mask-type:alpha">       <rect x=".1" y=".1" width=".8" height=".8"           fill="red" fill-opacity="0.7"/>     </mask>   </defs> </svg> 
CSS
.redsquare {   height: 100px;   width: 100px;   background-color: rgb(128, 128, 128);   border: solid 1px black;   mask: url("#m"); } 
Result

Setting a luminance mask

HTML
<div class="redsquare"></div> <svg version="1.1" xmlns="http://www.w3.org/2000/svg"     xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">   <defs>     <mask id="m" maskContentUnits="objectBoundingBox"       style="mask-type:luminance">       <rect x=".1" y=".1" width=".8" height=".8"           fill="red" fill-opacity="0.7"/>     </mask>   </defs> </svg> 
CSS
.redsquare {   height: 100px;   width: 100px;   background-color: rgb(128, 128, 128);   border: solid 1px black;   mask: url("#m"); } 
Result

Specifications

Specification
CSS Masking Module Level 1 # the-mask-type

See also

Other mask-related properties: mask, mask-mode

Last modified: Aug 12, 2021, by MDN contributors

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote


seren spirit :(
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.