How to make text unselectable using CSS?

You can not select this text! The user selection is disabled for this element.

To make a text unselectable in CSS, we use the user-select property. If you want a text not to be selected by the user, simply apply user-select: none; property on that particular element. It will prevent all kinds of selection events on the element.

Here is a working example:

Example:

p{
    user-select: none; 
    -webkit-user-select: none; /* Safari */        
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
}

Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.