How do I set span background-color so it colors the background throughout the line like in div (display: block; not an option)
css, html, javascript
Solution
you can achieve this by formatting your text in a different way. I have achieved what I believe you are looking for with the following:
<pre>
some text<span style="background-color:#ddd;">
and some text
with a different background</span>
and some more text
</pre>
Problem
I need to style some text within a pre-element. For that, I use an inline span-element like this: ``` <pre> some text <span style="background-color:#ddd;">and some text with a different background</span> and some more text </pre> ``` Then the html is rendered, the span-elements background is only changed underneath the text. Is it somehow possible to make the background-color extend throughout the line without changing display to block or inline-block. Or is there a way to achieve this with javascript?