If users need to select the generated text, it should be considered as content (and in HTML), not a presentation (and hidden in CSS).
Do not use ::before or ::after , use HTML.
You can use JavaScript to insert it (if that helps):
var text = document.createTextNode('Before - '); Array.prototype.forEach.call(document.getElementsByTagName('p'), function (p) { p.insertBefore(text.cloneNode(), p.firstChild); });
Thus, the text itself is present in the DOM, in contrast to the generated content from CSS.
source share