0

I want to insert some blank spaces in a line, but I don't want those blank spaces will be copied when the viewer select those...

Is there an easy way to do it?

rene
  • 41,474
  • 78
  • 114
  • 152
Nan Hua
  • 3,414
  • 3
  • 17
  • 24
  • Duplicate: http://stackoverflow.com/questions/826782/css-rule-to-disable-text-selection-highlighting – Alexei Darmin Jul 28 '15 at 23:31
  • for space just add ( ) -- that's a space. probably you need some javaScript to trim the spaces off when you select the text http://www.w3schools.com/jsref/jsref_trim_string.asp – Tasos Jul 28 '15 at 23:32
  • @AlexeiDarmin i would disagree, its not a duplicate since that is about no highlights and this is about copying. but there isn't any way to do what the user requested I think – Daemedeor Jul 28 '15 at 23:34
  • @ AlexeiDarmin -- thats not selecting text at all the OP does not want the spaces coppied – Tasos Jul 28 '15 at 23:35
  • @Tasos well trim only work at the beginning and end to begin with and then you'll have to capture "cntrl-c" and/or "command-c" and override the functionality, personally i'm against hijacking such standard functionality – Daemedeor Jul 28 '15 at 23:39
  • my suggestion is to take a spacer div/span and then add margin to it to space the needs..... – Daemedeor Jul 28 '15 at 23:42
  • Sorry guys, I should have made myself clear. Similar to what the answer below suggests, I imagined you do a `no select` class on each space. Then when the user tries to select text the spaces would be ignored. However the answer below also accounts for `ctrl + C` and `cmd + C` so it's even better. – Alexei Darmin Jul 29 '15 at 00:40
  • ok i undestand what you mean. You can use word-spacing http://www.w3schools.com/cssref/pr_text_word-spacing.asp – Tasos Jul 29 '15 at 14:17

1 Answers1

4

is it helpful?

<html>
  <head>
  </head>
  <style>
    .space{margin-left:50px}
  </style>
  <body>
    hello <span class="space"></span>world
  </body>
</html>
Zargaripour
  • 103
  • 1
  • 9