Code

Prevent text-selection of buttons

  • Category: Code
  • Last edited: June 16, 2016

How can you make a text link with your nice new styles behave like a button, instead of a selectable inline link? CSS, again, as the answer!

It is super easy to use javascript and CSS to simulate a button (for, say, a slider navigation or fake page navigation). But how do you get rid of that text selection when someone gets lazy with releasing the mouse? Use this css fool:

#element {
       -webkit-user-select: none;
       -khtml-user-select: none;
       -moz-user-select: none;
       -o-user-select: none;
       user-select: none;
}