What are the best practices for styling HTML tables, including borders, using PHP?

When styling HTML tables using PHP, it is best to use inline CSS or define a separate CSS file to control the appearance of the table, including borders. This allows for better organization and maintenance of the styling code. Additionally, using PHP to dynamically generate table elements can make it easier to apply consistent styles across multiple tables on a website.

<?php
echo '<table style="border-collapse: collapse; width: 100%;">';
echo '<tr><th style="border: 1px solid black;">Header 1</th><th style="border: 1px solid black;">Header 2</th></tr>';
echo '<tr><td style="border: 1px solid black;">Data 1</td><td style="border: 1px solid black;">Data 2</td></tr>';
echo '</table>';
?>