Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't do this with plain vanilla HTML, so JSF can't do much for you here as well.</p> <p>If you're targeting <a href="http://caniuse.com/#feat=user-select-none" rel="noreferrer">decent browsers</a> only, then just make use of CSS3:</p> <pre class="lang-css prettyprint-override"><code>.unselectable { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;label class="unselectable"&gt;Unselectable label&lt;/label&gt; </code></pre> <p>If you'd like to cover older browsers as well, then consider this JavaScript fallback:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;SO question 2310734&lt;/title&gt; &lt;script&gt; window.onload = function() { var labels = document.getElementsByTagName('label'); for (var i = 0; i &lt; labels.length; i++) { disableSelection(labels[i]); } }; function disableSelection(element) { if (typeof element.onselectstart != 'undefined') { element.onselectstart = function() { return false; }; } else if (typeof element.style.MozUserSelect != 'undefined') { element.style.MozUserSelect = 'none'; } else { element.onmousedown = function() { return false; }; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;label&gt;Try to select this&lt;/label&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If you're already using <a href="http://jquery.com" rel="noreferrer">jQuery</a>, then here's another example which adds a new function <code>disableSelection()</code> to jQuery so that you can use it anywhere in your jQuery code:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;SO question 2310734 with jQuery&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; &lt;script&gt; $.fn.extend({ disableSelection: function() { this.each(function() { if (typeof this.onselectstart != 'undefined') { this.onselectstart = function() { return false; }; } else if (typeof this.style.MozUserSelect != 'undefined') { this.style.MozUserSelect = 'none'; } else { this.onmousedown = function() { return false; }; } }); } }); $(document).ready(function() { $('label').disableSelection(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;label&gt;Try to select this&lt;/label&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload