ARTICLE AD BOX
On my website I have code snippets as rectangular areas with a scrollbar if the text overflows horizontally. I would like to mark insertions and deletions with <ins> and <del> and style those as lines with green and red background.
Something like this:
I want the green and red highlight to take the whole horizontal line even if the text is short, but if I just add width:100% then it cuts off long lines when scrolling. In snippets with overflowing lines, all highlighted lines should extend to the length of the longest:

The last image is what happens when I add width: 100%; display: block; to both <ins> and <del>, and also what I would like to avoid
I have seen this answer but I do not know how to apply that to my case.
5081 gold badge3 silver badges13 bronze badges
1
I tried declaring display: inline-block; min-width: 100%; for del, ins
Long lines of text are fully colored, but the lines are not all the same length (shorter lines end at 100% width.)
I wound up implementing display: grid on pre as Temani commented.
I don't know what whitespace-preserving features you are wanting to use pre for, but if you want single lines of text, you can also add white-space: nowrap; to avoid additional linebreaks between the lines.
3,1601 gold badge5 silver badges22 bronze badges
Explore related questions
See similar questions with these tags.
