Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to make double click select more than one word without Javascript?

Tags:

html

css

Let's say I have a web page which contains command line commands for the user to copy paste. Any way to display it with HTML/CSS which makes double clicking on one word select the entire command?

Example: ls -l /myfiles - clicking on "myfiles" here selects only that word, but for the user it'd be a better experience if the entire command was selected for easier copy-pasting. Again: No javascript is the question here.

like image 408
Nilzor Avatar asked Jan 08 '23 23:01

Nilzor


1 Answers

I commented in the question that selecting multiple words by double clicking is not possible without javascript. This is not totally true at least for firefox. I just found a way that will select multiple words by double clicking the first word!

You need to use a space followed by unicode ‏ (right-to-left mark)

Only works in Firefox!

jsfiddle demo

OR double click 'Hello' in the block qoute for demo.

Hello ‏my ‏name ‏is ‏Kasper

I don't know why this is working. I was just experimenting with unicodes... More info can be found on w3.org:

Using a Unicode right-to-left mark (RLM) or left-to-right mark (LRM) to mix text direction inline

EDIT:

Using other unicode space characters may be closer to the behaviour you want. For example unicode   DEMO (jsfiddle) OR double click any word in the block quote below (again, only works in firefox)

Hello my name is Kasper

other example (double click on a word with capitals)

in this SENTENCE ONLY WORDS WITH capitals are selected

like image 55
kasper Taeymans Avatar answered May 01 '23 17:05

kasper Taeymans