For a preformatted code fragment that has multiple lines, some of which are indented, the HTML element is <pre>. However, when I use this within a table, the browser inserts a blank line before and after the fragment, even when I don’t put the tags on separate lines. Is there a way to prevent this from happening?
For a preformatted code fragment that has multiple lines, some of which are indented,
Share
Yes. You need to remove the default padding and margin that the browser applies automatically to the element
pre.Do this
<pre style="padding:0; margin:0;"></pre>If this doesn’t remove all the blank space, add
display: inline;to the style attribute. By default it usedisplay: block;