cross browser - How to disable text selection highlighting using CSS? -
for anchors act buttons (for example, questions, tags, users, etc. @ top of stack overflow page) or tabs, there css standard way disable highlighting effect if user accidentally selects text?
i realize done javascript, , little googling yielded mozilla-only -moz-user-select
option.
is there standard-compliant way accomplish css, , if not, "best practice" approach?
update january, 2017:
according can use, user-select
supported in browsers except internet explorer 9 , earlier versions (but sadly still needs vendor prefix).
all of correct css variations are:
.noselect { -webkit-touch-callout: none; /* ios safari */ -webkit-user-select: none; /* safari */ -khtml-user-select: none; /* konqueror html */ -moz-user-select: none; /* firefox */ -ms-user-select: none; /* internet explorer/edge */ user-select: none; /* non-prefixed version, supported chrome , opera */ }
<p> selectable text. </p> <p class="noselect"> unselectable text. </p>
note it's non-standard feature (i.e. not part of specification). not guaranteed work everywhere, , there might differences in implementation among browsers , in future browsers can drop support it.
more information can found in mozilla developer network documentation.
Comments
Post a Comment