I'm currently working on integrating line numbers into a code snippet. I've managed to get it functioning, but there's an issue with the border between the line number and the code. Instead of being continuous, there are small, unsightly gaps.
Even after using Inspect Element, I can't seem to pinpoint the cause of the spacing problem.
I've experimented with adjusting the line-height
, but so far, I haven't found a solution that doesn't drastically impact the spacing.
pre {
counter-reset: linenum;
font-family: "DejaVu Sans Mono";
}
pre code {
counter-increment: linenum;
}
pre code::before {
content: counter(linenum);
display: inline-block;
width: 3em;
text-align: right;
padding-right: 0.5em;
margin-right: 0.5em;
color: #888;
border-right: 1px solid #888;
}
<pre>
<code>Line one</code>
<code>Line two</code>
<code>Line three</code>
</pre>