In PHP, what are some best practices for designing tables with background colors that maintain readability across different output formats like print or fax?

When designing tables with background colors in PHP, it's important to choose colors that maintain readability across different output formats like print or fax. To ensure this, it's recommended to use colors that have a high contrast ratio, such as dark text on a light background or vice versa. Additionally, consider providing an option to switch to a printer-friendly version of the table for better readability in print format.

<style>
    table {
        border-collapse: collapse;
        width: 100%;
    }
    th, td {
        border: 1px solid black;
        padding: 8px;
    }
    tr:nth-child(even) {
        background-color: #f2f2f2; /* light background color */
    }
    @media print {
        tr:nth-child(even) {
            background-color: #fff; /* white background color for print */
        }
    }
</style>

<table>
    <tr>
        <th>Header 1</th>
        <th>Header 2</th>
    </tr>
    <tr>
        <td>Data 1</td>
        <td>Data 2</td>
    </tr>
</table>