Set an HTML element to select completely on one click

article #1254, updated 1979 days ago

Add this to the style of an element (P, H3, DIV, etc.):

-webkit-touch-callout: all; /* iOS Safari */
-webkit-user-select: all; /* Safari */
-khtml-user-select: all; /* Konqueror HTML */
-moz-user-select: all; /* Firefox */
-ms-user-select: all; /* Internet Explorer/Edge */
user-select: all; /* Chrome and Opera */

and if you click once on any part of the element, the whole thing is selected/highlighted, ready to be copied to clipboard. No JavaScript!

Categories: