What are the best practices for aligning and styling HTML table cells in PHP output, considering modern CSS standards?

When outputting HTML tables in PHP, it's important to use CSS for styling to ensure a consistent and modern look. To align and style table cells, you can use CSS classes to target specific cells and apply styling rules such as text-align, padding, and borders. By separating the PHP logic from the presentation layer, you can maintain clean and readable code.

<?php
echo '<table>';
echo '<tr>';
echo '<th class="header">Header 1</th>';
echo '<th class="header">Header 2</th>';
echo '</tr>';
echo '<tr>';
echo '<td class="align-left">Row 1 Cell 1</td>';
echo '<td class="align-right">Row 1 Cell 2</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="align-left">Row 2 Cell 1</td>';
echo '<td class="align-right">Row 2 Cell 2</td>';
echo '</tr>';
echo '</table>';
?>
```

CSS:
```css
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border: 1px solid #ddd;
  padding: 8px;
}

th.header {
  background-color: #f2f2f2;
}

td.align-left {
  text-align: left;
}

td.align-right {
  text-align: right;
}