How can CSS be utilized to address layout issues when displaying multiple tables side by side on varying screen sizes in PHP?
When displaying multiple tables side by side on varying screen sizes in PHP, CSS can be utilized to create a responsive layout. By using CSS media queries, you can adjust the styling of the tables based on the screen size, ensuring they display properly side by side on all devices.
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
@media only screen and (min-width: 600px) {
table {
width: 50%;
float: left;
}
}
</style>
</head>
<body>
<table>
<tr>
<th>Table 1 Header</th>
</tr>
<tr>
<td>Table 1 Data</td>
</tr>
</table>
<table>
<tr>
<th>Table 2 Header</th>
</tr>
<tr>
<td>Table 2 Data</td>
</tr>
</table>
</body>
</html>