What are some common methods for styling tables in PHP to improve readability?
When displaying data in tables using PHP, it is important to style the tables to improve readability for users. Common methods for styling tables include using CSS to set background colors, borders, padding, and text alignment. By applying these styles, you can make the table easier to read and navigate for users.
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="background-color: #f2f2f2; padding: 10px;">Name</th>
<th style="background-color: #f2f2f2; padding: 10px;">Age</th>
<th style="background-color: #f2f2f2; padding: 10px;">Location</th>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 10px;">John Doe</td>
<td style="border: 1px solid #ddd; padding: 10px;">25</td>
<td style="border: 1px solid #ddd; padding: 10px;">New York</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 10px;">Jane Smith</td>
<td style="border: 1px solid #ddd; padding: 10px;">30</td>
<td style="border: 1px solid #ddd; padding: 10px;">Los Angeles</td>
</tr>
</table>