How can the base tag in HTML be utilized to address issues with relative CSS paths in PHP?
When using PHP to generate HTML content, relative paths in CSS files can become problematic if the CSS file is located in a different directory than the HTML file. To address this issue, the base tag in HTML can be utilized to specify the base URL for all relative URLs in the document, including CSS paths. By setting the base tag in the HTML head section, all relative paths in the CSS file will be resolved correctly.
<?php
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<base href="http://www.example.com/css/">';
echo '<link rel="stylesheet" type="text/css" href="styles.css">';
echo '</head>';
echo '<body>';
// Your PHP code to generate HTML content goes here
echo '</body>';
echo '</html>';
?>