When I want to show lines with line numbers, I typically use this template for each line:
<div><span style="display: inline-block;width: 50px;">1</span><span>line1</span></div>
<div><span style="display: inline-block;width: 50px;">2</span><span>line2</span></div>
The problem arises when selecting text with the mouse, as the line numbers are also included. Can someone advise on how to modify the code above so that only 'line1' and 'line2' will be selected and copied to the clipboard?
Is it possible to achieve this through CSS/HTML alone, or would a more advanced approach such as JavaScript or jQuery be necessary?
Thank you, M.