Today I Learned

A Hashrocket project

Prevent a User From Selecting Text

Today I learned about a CSS property called user-select. You might use it like this, to prevent a user from selecting text:

p {
  user-select: none;
}

I discovered this on an event booking website: the event description links were not anchor tags, and the content on the page was not selectable.

If you’re going to disable default behavior on a website, you need to have a good reason. My assumption (which could be wrong) is that the site creators don’t want me to select text on the page and start searching around for a better deal. I don’t think that’s a good enough reason, because there are plenty of cases where a user might copy text on a page that don’t hurt (or actually support) the event organizer’s business.

docs