concept

Svg pointer targeting — CSS reference

SVG offers geometry-aware hit-testing values. Stroke targets the stroke region even when the stroke paint is none; fill regions are excluded with this value. This example tests a visible outline and its painted center, which is excluded from targeting.

Formal Syntax & Structure

css syntaxcss
pointer-events: stroke;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>SVG pointer targeting</title><style>body{margin:0;background:white}svg{display:block}#a{pointer-events:stroke}</style><body><svg xmlns="http://www.w3.org/2000/svg" width="240" height="160" viewBox="0 0 240 160" role="img" aria-label="SVG styling example"><rect id="a" x="40" y="40" width="100" height="80" fill="red" stroke="blue" stroke-width="12"/></svg></body></html>
CSS Reference