JavaScript<\/a> solution that can be used for older web browsers.<\/p>\n\n\n\nThe user-select syntax and available variations:<\/p>\n\n\n\n
.dontselect {\n -webkit-touch-callout: none; \/* iOS Safari *\/\n -webkit-user-select: none; \/* Safari *\/\n -khtml-user-select: none; \/* Konqueror HTML *\/\n -moz-user-select: none; \/* Old versions of Firefox *\/\n -ms-user-select: none; \/* Internet Explorer\/Edge *\/\n user-select: none; \/* Non-prefixed version, currently\n supported by Chrome, Edge, Opera and Firefox *\/\n}<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
Usage in HTML:<\/p>\n\n\n\n
<p>\n Selectable text.\n<\/p>\n<p class="dontselect">\n Non-selectable text.\n<\/p><\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
The following JavaScript solution can be used in Internet Explorer 9 and older browser versions to disable text selection highlighting:<\/p>\n\n\n\n
onSelectStart="return false;"<\/code><\/pre>\n\n\n\nUsage in HTML:<\/p>\n\n\n\n
<p>\n Selectable text.\n<\/p>\n<p onselectstart="return false;">\n Non-selectable text.\n<\/p><\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
Bonus Tip to Disable Text Selection Highlighting<\/h2>\n\n\n\n You may also want to prevent the context menu from appearing on elements like buttons that have their selection prevented. To do that, add this code to the entire page, or just those button elements:<\/p>\n\n\n\n
$("body").on("contextmenu",function(e){\n return false;\n});<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
or:<\/p>\n\n\n\n
$("#buttonId").on("contextmenu",function(e){\n return false;\n});<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"You can use CSS for many things and one of the uses is to disable text selection in your text, tabs, buttons, and more. This can be done using the…<\/p>\n","protected":false},"author":1,"featured_media":9330,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,9,27,16],"tags":[106,170,303,328,635],"yoast_head":"\n
How to Disable Text Selection Highlighting Using CSS<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n