Here's an HTML showing some code in between two short lines of text
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Uffa</title>
<style type="text/css" media="screen">
pre {
margin: 0;
}
</style>
</head>
<body>
line before
<pre><code>
some
code
here
</code></pre>
line after
</body>
</html>
When I hover with the mouse via devtools, I see this:
and I don't understand where the vertical spacing before and after the code chunk comes from.
Below is the live snippet, in which, however, only the top space of my example is reproduced.
pre {
margin: 0;
}
line before
<pre><code>
some
code
here
</code></pre>
line after
I have simplified my use case a lot to ask this question. And after the the simplification, I still see the same issue I was concerned about.
However, as somebody suggested to use <pre>
without nesting <code>
into it, I should probably clarify that in the original use case, I'm making use of highlight.js
, which prescribes to write code in between <pre><code class="language-whatever">
and </code></pre>
.