pointer-events

  • Revision slug: CSS/pointer-events
  • Revision title: pointer-events
  • Revision id: 25368
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment 11 words added

Revision Content

{{ CSSRef() }}

Introduced in Firefox 1.5 (Gecko 1.8) for SVG content.

Extended in Firefox 3.6 (Gecko 1.9.2) to all other content (HTML etc.)

Summary

The CSS property pointer-events allows authors to control whether or when an element may be the target of a mouse event. This property is used to specify under which circumstance (if any) a mouse event should go "through" an element and target whatever is "underneath" that element instead.

  • {{ Xref_cssinitial() }}: auto
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: yes
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: the specified value, or else the inherited value

Syntax

pointer-events:  auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit

Values

Note: as of Firefox 3.6, only the values auto and none apply to all elements. The other values only apply to SVG and behave like auto in other XML and HTML content.

auto
The element behaves as it would if the pointer-events property was not specified. In SVG content this value and the value visiblePainted have the same effect.
none
The element is never the target of mouse events, although mouse events may target its descendant elements if those descendants have pointer-events set to some other value, in which case mouse events will trigger event listeners on this element as appropriate on their way to/from the descendant during the event capture/bubble phases.
visiblePainted
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the interior (i.e., 'fill') of the element and the fill property is set to a value other than none, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the stroke property is set to a value other than none.
visibleFill
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the interior (i.e., fill) of the element. The value of the fill property does not effect event processing.
visibleStroke
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the perimeter (i.e., stroke) of the element. The value of the stroke property does not effect event processing.
visible
SVG only. The element can be the target of a mouse event when the visibility property is set to visible and the mouse cursor is over either the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the fill and stroke do not effect event processing.
painted
SVG only. The element can only be the target of a mouse event when the mouse cursor is over the interior (i.e., 'fill') of the element and the fill property is set to a value other than none, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the stroke property is set to a value other than none. The value of the visibility property does not effect event processing.
fill
SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) of the element. The values of the fill and visibility properties do not effect event processing.
stroke
SVG only. The element can only be the target of a mouse event when the pointer is over the perimeter (i.e., stroke) of the element. The values of the stroke and visibility properties do not effect event processing.
all
SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the fill, stroke and visibility properties do not effect event processing.

Examples

{{ CSSRefExampleLink("pointer-events") }} (not available, please check later)

Notes

Note that preventing an element from being the target of mouse events by using pointer-events does not necessarily mean that mouse event listeners on that element cannot or will not be triggered. If one of the element's children has pointer-events explicitly set to allow that child to be the target of mouse events, then any events targeting that child will pass through the parent as the event travels along the parent chain, and trigger event listeners on the parent as appropriate. Of course any mouse activity at a point on the screen that is covered by the parent but not by the child will not be caught by either the child or the parent (it will go "through" the parent and target whatever is underneath).

Mozilla and other W3C members would like to provide finer grained control (than just auto and none) in HTML for which parts of an element will cause it to "catch" mouse events, and when. To help us in deciding how pointer-events should be further extended for HTML, if you have any particular things that you would like to be able to do with this property, then please add them to the Use Cases section of this wiki page (don't worry about keeping it tidy), or else send them to Jonathan Watt.

Browser compatibility

Browser SVG support HTML/XML content
Internet Explorer --- ---
Firefox (Gecko) 1.5 (1.8) 3.6 (1.9.2)
Opera (Presto) 9.0 (2.0) ---
Safari | Chrome | WebKit 3.0 | 1.0 | 522 4.0 | 2.0 | 530

Specifications

See also

Revision Source

<p>{{ CSSRef() }}</p>
<div style="border: 1px solid maroon; margin: 10px 0px; padding: 0px 10px; overflow: hidden; background-color: rgb(254, 244, 156); font-weight: bold; text-align: center;">
<p style="margin: 4px 0px;">Introduced in Firefox 1.5 (Gecko 1.8) for SVG content.</p>
<div>Extended in Firefox 3.6 (Gecko 1.9.2) to all other content (HTML etc.)</div>
</div>
<h3>Summary</h3>
<p>The CSS property<code> pointer-events </code>allows authors to control whether or when an element may be the <a class="internal" href="/en/DOM/event.target" title="en/DOM/event.target">target</a> of a mouse event. This property is used to specify under which circumstance (if any) a mouse event should go "through" an element and target whatever is "underneath" that element instead.</p>
<ul> <li>{{ Xref_cssinitial() }}: auto</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: yes</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: the specified value, or else the inherited value</li>
</ul>
<h3>Syntax</h3>
<pre style="white-space:pre-wrap">pointer-events:  <em>auto</em> | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit
</pre>
<h3>Values</h3>
<p>Note: as of Firefox 3.6, only the values<code> auto </code>and<code> none </code>apply to all elements. The other values only apply to <a class="internal" href="/en/SVG" title="en/SVG">SVG</a> and behave like<code> auto </code>in other XML and HTML content.</p>
<dl> <dt>auto</dt> <dd>The element behaves as it would if the<code> pointer-events </code>property was not specified. In SVG content this value and the value<code> visiblePainted </code>have the same effect.</dd> <dt>none</dt> <dd>The element is never the <a class="internal" href="/en/DOM/event.target" title="en/DOM/event.target">target</a> of mouse events, although mouse events may target its descendant elements if those descendants have<code> pointer-events </code>set to some other value, in which case mouse events will trigger event listeners on this element as appropriate on their way to/from the descendant during the event capture/<a class="internal" href="/en/DOM/event.bubbles" title="en/DOM/event.bubbles">bubble</a> phases.</dd> <dt>visiblePainted</dt> <dd>SVG only. The element can only be the target of a mouse event when the<code> visibility </code>property is set to<code> visible </code>and when the mouse cursor is over the interior (i.e., 'fill') of the element and the<code> fill </code>property is set to a value other than <code>none</code>, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the<code> stroke </code>property is set to a value other than<code> none</code>.</dd> <dt>visibleFill</dt> <dd>SVG only. The element can only be the target of a mouse event when the<code> visibility </code>property is set to<code> visible </code>and when the mouse cursor is over the interior (i.e., fill) of the element. The value of the<code> fill </code>property does not effect event processing.</dd> <dt>visibleStroke</dt> <dd>SVG only. The element can only be the target of a mouse event when the<code> visibility </code>property is set to<code> visible </code>and when the mouse cursor is over the perimeter (i.e., stroke) of the element. The value of the<code> stroke </code>property does not effect event processing.</dd> <dt>visible</dt> <dd>SVG only. The element can be the target of a mouse event when the<code> visibility </code>property is set to<code> visible </code>and the mouse cursor is over either the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the<code> fill </code>and<code> stroke </code>do not effect event processing.</dd> <dt>painted</dt> <dd>SVG only. The element can only be the target of a mouse event when the mouse cursor is over the interior (i.e., 'fill') of the element and the<code> fill </code>property is set to a value other than <code>none</code>, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the<code> stroke </code>property is set to a value other than<code> none</code>. The value of the<code> visibility </code>property does not effect event processing.</dd> <dt>fill</dt> <dd>SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) of the element. The values of the<code> fill </code>and<code> visibility </code>properties do not effect event processing.</dd> <dt>stroke</dt> <dd>SVG only. The element can only be the target of a mouse event when the pointer is over the perimeter (i.e., stroke) of the element. The values of the<code> stroke </code>and<code> visibility </code>properties do not effect event processing.</dd> <dt>all</dt> <dd>SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the<code> fill</code>,<code> stroke </code>and<code> visibility </code>properties do not effect event processing.</dd>
</dl>
<h3>Examples</h3>
<p>{{ CSSRefExampleLink("pointer-events") }} <span class="lang lang-en">(not available, please check later) </span></p>
<h3>Notes</h3>
<p>Note that preventing an element from being the target of mouse events by using<code> pointer-events </code>does <em>not</em> necessarily mean that mouse event listeners on that element <em>cannot</em> or <em>will not</em> be triggered. If one of the element's children has<code> pointer-events </code>explicitly set to <em>allow</em> that child to be the target of mouse events, then any events targeting that child will pass through the parent as the event travels along the parent chain, and trigger event listeners on the parent as appropriate. Of course any mouse activity at a point on the screen that is covered by the parent but not by the child will not be caught by either the child or the parent (it will go "through" the parent and target whatever is underneath).</p>
<p>Mozilla and other W3C members would like to provide finer grained control (than just<code> auto </code>and<code> none</code>) in HTML for which parts of an element will cause it to "catch" mouse events, and when. To help us in deciding how<code> pointer-events </code>should be further extended for HTML, if you have any particular things that you would like to be able to do with this property, then please add them to the Use Cases section of <a class=" link-https" href="https://wiki.mozilla.org/SVG:pointer-events">this wiki page</a> (don't worry about keeping it tidy), or else send them to <a class=" link-mailto" href="mailto:jwatt@jwatt.org">Jonathan Watt</a>.</p>
<h3>Browser compatibility</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>SVG support</th> <th>HTML/XML content</th> </tr> <tr> <td>Internet Explorer</td> <td>---</td> <td>---</td> </tr> <tr> <td>Firefox (Gecko)</td> <td>1.5 (1.8)</td> <td>3.6 (1.9.2)</td> </tr> <tr> <td>Opera (Presto)</td> <td>9.0 (2.0)</td> <td>---</td> </tr> <tr> <td>Safari | Chrome | WebKit</td> <td>3.0 | 1.0 | 522</td> <td>4.0 | 2.0 | 530</td> </tr> </tbody>
</table><h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty">SVG 1.1 Interactivity #PointerEvents</a></li> <li><a class=" external" href="http://dev.w3.org/csswg/css3-ui/#pointer-events" title="http://dev.w3.org/csswg/css3-ui/#pointer-events">CSS 3 Basic User Interface #pointer-events</a>  Editor's draft (work in progress)</li>
</ul><h3>See also</h3>
<ul> <li>The SVG attribute {{ SVGAttr("pointer-events") }}</li> <li><a class="external" href="http://webkit.org/specs/PointerEventsProperty.html" title="http://webkit.org/specs/PointerEventsProperty.html">WebKit Specs PointerEventsProperty</a> extended for use in (X)HTML content</li>
</ul>
Revert to this revision