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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With