What are the best practices for styling and formatting data output in PHP scripts?

When styling and formatting data output in PHP scripts, it is important to use proper HTML markup and CSS to ensure a clean and organized display. This includes using appropriate tags for headings, paragraphs, lists, tables, and styling elements such as colors, fonts, and spacing. Additionally, consider using PHP functions to format data before outputting it, such as date formatting or number formatting.

<!DOCTYPE html>
<html>
<head>
    <title>Data Output Styling</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            color: #333;
            margin: 0;
            padding: 0;
        }
        h1 {
            color: #007bff;
        }
        table {
            border-collapse: collapse;
            width: 100%;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>
    <h1>Users List</h1>
    <table>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Email</th>
        </tr>
        <?php
            // Sample data output
            $users = [
                ['id' => 1, 'name' => 'John Doe', 'email' => 'john.doe@example.com'],
                ['id' => 2, 'name' => 'Jane Smith', 'email' => 'jane.smith@example.com']
            ];

            foreach ($users as $user) {
                echo "<tr>";
                echo "<td>{$user['id']}</td>";
                echo "<td>{$user['name']}</td>";
                echo "<td>{$user['email']}</td>";
                echo "</tr>";
            }
        ?>
    </table>
</body>
</html>