mask-type

  • Revision slug: Web/CSS/mask-type
  • Revision title: mask-type
  • Revision id: 449935
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }} {{SeeCompatTable}}

The CSS mask-type properties defines if a SVG {{SVGElement("mask")}} element is a luminance or an alpha mask.

  • {{ Xref_cssinitial() }} luminance
  • Applies to {{SVGElement("mask")}}
  • {{ Xref_cssinherited() }} no
  • Media {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }} {{cssuniqueorderdef}}
  • Animatable {{cssnotanimatabledef}}

Syntax

mask: luminance | alpha

Values

luminance
Is a keyword indicating that the associated {{SVGElement("mask")}} is a luminance mask, that is that its relative luminance values must be used when applying it.
alpha
Is a keyword indicating that the associated {{SVGElement("mask")}} is an alpha mask, that is that its alpha channel values must be used when applying it.

Examples

Let's apply the following mask:

mask

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect x="10" y="10" width="80" height="80" fill="red" fill-opacity="0.7"/>
</svg>
{{ EmbedLiveSample('mask', '100%', '100') }}

box

to this box:

.redsquare {
    height: 100px;
    width: 100px;
    background-color: rgb(128, 128, 128);
    border: solid 1px black;
}
<div class="redsquare"></div>
{{ EmbedLiveSample('box', '100%', '100') }}

jjjj

Specifications

Specification Status Comment
{{ SpecName('CSS Masks', '#mask-type', 'mask') }} {{ Spec2('CSS Masks') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 24.0 {{CompatGeckoDesktop("20.0")}} {{ CompatNo() }} 15.0 {{ CompatNo() }}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{CompatGeckoMobile("20.0")}} {{ CompatNo() }} 15.0 {{ CompatNo() }}

See also

  • Other mask-related properties: {{cssxref("mask")}}

Revision Source

<div>
  {{ CSSRef() }} {{SeeCompatTable}}</div>
<p>The CSS <code>mask-type</code> properties defines if a SVG {{SVGElement("mask")}} element is a <em>luminance</em> or an <em>alpha mask</em>.</p>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}</dfn> <code>luminance</code></li>
  <li><dfn>Applies to</dfn> {{SVGElement("mask")}}</li>
  <li><dfn>{{ Xref_cssinherited() }}</dfn> no</li>
  <li><dfn>Media</dfn> {{ Xref_cssvisual() }}</li>
  <li><dfn>{{ Xref_csscomputed() }}</dfn> {{cssuniqueorderdef}}</li>
  <li><dfn>Animatable</dfn> {{cssnotanimatabledef}}</li>
</ul>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
mask: luminance | alpha</pre>
<h3 id="Values" name="Values">Values</h3>
<dl>
  <dt>
    <code>luminance</code></dt>
  <dd>
    Is a keyword indicating that the associated {{SVGElement("mask")}} is a luminance mask, that is that its <a href="http://en.wikipedia.org/wiki/Luminance_%28relative%29" title="http://en.wikipedia.org/wiki/Luminance_%28relative%29">relative luminance</a> values must be used when applying it.</dd>
  <dt>
    <code>alpha</code></dt>
  <dd>
    Is a keyword indicating that the associated {{SVGElement("mask")}} is an alpha mask, that is that its <a href="http://en.wikipedia.org/wiki/Alpha_compositing" title="http://en.wikipedia.org/wiki/Alpha_compositing"><em>alpha channel</em></a> values must be used when applying it.</dd>
</dl>
<h2 id="Examples" name="Examples">Examples</h2>
<p>Let's apply the following mask:</p>
<h3 id="mask">mask</h3>
<pre class="brush: html">
&lt;svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
  &lt;rect x="10" y="10" width="80" height="80" fill="red" fill-opacity="0.7"/&gt;
&lt;/svg&gt;
</pre>
<div>
  {{ EmbedLiveSample('mask', '100%', '100') }}</div>
<h3 id="box">box</h3>
<p>to this box:</p>
<pre class="brush: css">
.redsquare {
&nbsp;&nbsp;&nbsp; height: 100px;
&nbsp;&nbsp;&nbsp; width: 100px;
&nbsp;&nbsp;&nbsp; background-color: rgb(128, 128, 128);
&nbsp;&nbsp;&nbsp; border: solid 1px black;
}
</pre>
<pre class="brush: html">
&lt;div class="redsquare"&gt;&lt;/div&gt;
</pre>
<div>
  {{ EmbedLiveSample('box', '100%', '100') }}</div>
<p>jjjj</p>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('CSS Masks', '#mask-type', 'mask') }}</td>
      <td>{{ Spec2('CSS Masks') }}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>24.0</td>
        <td>{{CompatGeckoDesktop("20.0")}}</td>
        <td>{{ CompatNo() }}</td>
        <td>15.0</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{CompatGeckoMobile("20.0")}}</td>
        <td>{{ CompatNo() }}</td>
        <td>15.0</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>Other mask-related properties: {{cssxref("mask")}}</li>
</ul>
Revert to this revision