How to avoid the margin inside pre tag:
<p>Some text</p>
<pre>
<code>
Some code
</code>
</pre>
<p>Some text</p>
<style>
pre {
background-color: rgb(255,247,229);
border: 1px solid red;
}
</style>
The current output:
The desired output:
The current solution is to manually remove the indentation in the markup, like shown below. However, as I understand, it is not the optimal way.
<pre>
<code>
Some code
</code>
</pre>
You can try changing the default value of white-space for <pre> tag from pre to pre-line.
pre-lineSequences of whitespace are collapsed. Lines are broken at newline characters, at<br>, and as necessary to fill line boxes.
Read more about white-space on MDN.
pre {
background-color: rgb(255, 247, 229);
border: 1px solid red;
white-space: pre-line;
}
<p>Some text</p>
<pre>
<code>
Some code
</code>
</pre>
<p>Some text</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With