JSFiddle - React, Tailwind, and code Playground

HTML

<pre id="print-content"> (<span class='light'>highlighted</span> portion) </pre>
<div>abc 123</div>
<button id="save">Print</button>

CSS

.light {
    color:#0af;
}
#print-content {
    display:none;
}

JavaScript

$("#save").click(function () {
    var text = $("body").clone();
    text.find("#print-content").attr("style", "display:block");
    text.find("#save, script").remove();
    var styles = $("style")[0].outerHTML;
    var popup = window.open("", "popup");
    popup.document.body.innerHTML = text[0].outerHTML + styles;
    popup.focus();
    popup.print();
});