-2

I have a large, multiline body of HTML, resulting from applying an explicit line breaking algorithm to a text string. I'd like to add spans within that HTML to indicate where I've forced a line break, by embedding certain spans with a particular character.

However, if I actually use a character it appears when multiple lines are copied and pasted elsewhere. I can use a span with an image, but that is significantly less efficient.

Is there some other way?

Uri
  • 86,748
  • 48
  • 217
  • 319
  • There is https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy, but it's not standard. – Marc B Jul 22 '16 at 21:01

1 Answers1

3

No, but CSS Generated content is not copied:

span::after {
  content: "<I won't be copied>";
  display: block;
}
<div>
  Hello<span></span>World!<span></span>Foo<span></span>Bar<span></span>Baz
</div>

Of course, you should only use this for styling purposes, not for content.

Oriol
  • 249,902
  • 55
  • 405
  • 483