Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
By default browsers let us select the text in the browser using the keyboard, pressing the cmd-A combination on a Mac for example, or using the mouse.
How can you disable that, to make your web page behave more like an app and less like a document?
Use the user-select: none; CSS rule.
You need to use browser prefixes, as https://caniuse.com/#feat=user-select-none tells us:
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
One approach I use is to make the entire app interface unselectable by applying user-select: none; on the body element, then re-enabling selection on specific elements with:
user-select: text;