Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Created January 3, 2015 13:41
Show Gist options
  • Save 23maverick23/64b3b587c88697558fac to your computer and use it in GitHub Desktop.
Save 23maverick23/64b3b587c88697558fac to your computer and use it in GitHub Desktop.
CSS: Disable text selection in SVG elements
svg text {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
svg text::selection {
background: none;
}
@quentindemetz
Copy link

I have found that putting event.preventDefault() in the onclick callback fixes this behavior

@ryantan
Copy link

ryantan commented Oct 20, 2018

I had to add

pointer-events: none;

@taiwanhua
Copy link

svg text {
fill: "transparent"
}
svg text::selection {
fill: "transparent"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment