I am using HighlightJS to highlight my code. How do I reset the spacing between pre and code tags (marked with the gray background)? I set both the padding and margin of both pre and code tags to 0 but that doesnt seem to work. Ideally I would like the code tag to occupy the complete height of the pre tag. Could you please let me know how I can do that?
pre{ background: gray; margin: 0 !important; padding: 0 !important; } code{ margin: 0 !important; padding: 0 !important; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/color-brewer.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> <pre> <code class="html"> <!DOCTYPE html> <html> <title>HTML Tutorial</title> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html> </code> </pre>
Or you remove this line break from your code :
<pre>
<code class="html">
like this :
<pre><code class="html">
or you reset the white space properties of those 2 tags :
pre{ background: gray; white-space:normal; } pre code{ white-space:pre; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/color-brewer.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> <pre> <code class="html"> <!DOCTYPE html> <html> <title>HTML Tutorial</title> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html> </code> </pre>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.