How to disable text selection on a web page using HTML & CSS

Hi, Today I am going to show you how to disable selected text on a web page. In this article we will learn how to disable selected text on a web page using css.

Example

<!DOCTYPE html>

<html>

<head>

    <title>THIS IS A TITLE</title>

    <style type="text/css">
        body {

            user-select: none;
            /* supported by Chrome and Opera */
            -webkit-user-select: none;
            /* Safari */
            -khtml-user-select: none;
            /* Konqueror HTML */
            -moz-user-select: none;
            /* Firefox */
            -ms-user-select: none;
            /* Internet Explorer/Edge */
        }
    </style>

</head>

<body>



    <h1>How to disable text selection on html web page using JQuery?</h1>



    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
        aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
        sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>



</body>

</html>

Hope it helps …

Leave a Reply