0 votes
1 view
in Web Technology by (47.8k points)

For anchors that act like buttons (for example, Questions, Tags, Users, etc. at the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text?

I realize this could be done with JavaScript, and a little googling yielded the Mozilla-only -moz-user-select option.

Is there a standard-compliant way to accomplish this with CSS, and if not, what is the "best practice" approach?

1 Answer

0 votes
by (107k points)

If you want to disable text selection highlighting you can use the below-mentioned way:-

To enforce the entire element which gets selected, you can also use the below-mentioned CSS code, if you click on an element, all the text wrapped in that element will get selected. For this, all you have to do is changing the value none to all. See the code below:-

.force-select {

-webkit-user-select: all; 

-moz-user-select: all; 

-ms-user-select: all; 

user-select: all; 


Welcome to Intellipaat Community. Get your technical queries answered by top developers !