How can CSS be used to format print output in PHP?

To format print output in PHP using CSS, you can include a <style> tag in the HTML code that you are generating with PHP. Within the <style> tag, you can define CSS rules to style the print output as needed. This allows you to control the appearance of the printed content, such as setting fonts, colors, margins, and other formatting options.

&lt;?php
header(&quot;Content-type: text/css&quot;);
echo &quot;
&lt;style&gt;
    body {
        font-family: Arial, sans-serif;
        color: #333;
        margin: 0;
        padding: 0;
    }
    
    h1 {
        color: #007bff;
    }
&lt;/style&gt;
&quot;;
?&gt;