Today I Learned - Rocky Kev

TIL Disable users from highlighting text

POSTED ON:

TAGS:

I get it. You got a request from your boss to be a terrible human being.

They want to disable right-clicks.
They want to disable zoom to really hurt the accessibility.
They want to remove highlighting.

Heck, if they had it their way, you'll have to do a blood sacrifice to see their 'precious' content.

Well, to at least remove highlighting --

You can use the user-select property to prevent an element from being highlighted by the user.

.no-highlight {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}

mdn user-select


Related TILs

Tagged:

TIL Gmail has a 102KB size-limit for HTML

PLACEHOLDER

TIL how Error correction works in HTML

You never get an 'Invalid Syntax' error on an HTML page. Browsers fix any invalid content and go on.

TIL what DOCTYPE means

tl;dr: DOCTYPE declaration in the first line of the HTML file, to instruct the browser to run the code in Standard mode.