how can I control the styles of the printed page?
===

I've added 3 print buttons to my web page, each one printing a portion(div) of the web page.
Here is the code for that

    function printPage(id)
    {
       var html="<html>";
       //html+="<link rel="stylesheet" type="text/css" href="../css/template.css" />";
       html+= document.getElementById(id).innerHTML;
       html+="</html>";
    
       var printWin = window.open('','_blank','left=0,top=0,width=500,height=500,fullscreen=1,toolbar=0,scrollbars=0,status  =0');
       printWin.document.write(html);
       printWin.document.close();
       printWin.focus();
       printWin.print();
       printWin.close();
    }
   

     <input name="b_print" type="button" class="ipt"   onClick="printPage('one');" value="Print One">
    <input name="b_print" type="button" class="ipt"   onClick="printPage('two');" value="Print Two">
    <input name="b_print" type="button" class="ipt"   onClick="printPage('three');" value="Print three">

So when i click on the button 'Print', a new window opens, print successfully and close it.
I have few questions about this

Firstly, i want to popup the print window in the same page. For that i've replaced `_blank` property in `window.open` with `_parent`, but after printing, the page is not redirecting or going back to the page where i've initiated the print. How to avoid this?

Secondly, how can I control the styles of the printed page? I've tried to link a stylesheet (as shown above in the code) but it doesn't work.

Thanks in advance for any help or suggestions