We are building a web app that allows elements to be expanded/collapsed.
One of the clickable items is shown below:
Notice the text selection when clicking on the element is annoying. What is the recommended approach for handling this?
We are building a web app that allows elements to be expanded/collapsed.
One of the clickable items is shown below:
Notice the text selection when clicking on the element is annoying. What is the recommended approach for handling this?
For Firefox and Chrome/Safari you can use the user select property.
It is still experimental I think so you should use vendor prefixes like this:
#element-id{-moz-user-select: none; -webkit-user-select: none;}
As for Opera and IE I have no idea (maybe for Opera using -o-user-select will work, but I am not sure)
EDIT: I looked around a bit, because I was also interested in this question and apparently, for Opera and IE there is an unselectable
property. More details about it
To disable selection in a CSS way:
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
or you may use element attribute unselectable
<div unselectable="on">...</div>