How to remove the first blank line in a HTML code block

Page breadcrumbsEnd of page breadcrumbs

It can be very irritating when you put a piece of code in your code tag and encounter afterwards that you have a single blank line in the beginning of your code.

I have good news for you! I made a simple fix that you can easily put in the end of your body tag to solve this problem.

Copy this snippet and place it at the end of your body tag. It removes the first new line from each code block

<script>
var y = document.querySelectorAll("pre code");
for(var i = 0; i < y.length; i++) {
  y[i].innerHTML = y[i].innerHTML.replace("\n", "");
}
</script>
Tags: