What are the best practices for styling text output in PHP to ensure compatibility with modern web standards?

When styling text output in PHP for web applications, it is important to use CSS for styling instead of inline styles or deprecated HTML tags. This ensures compatibility with modern web standards and separation of content from presentation. By creating CSS classes and applying them to HTML elements generated by PHP, you can maintain a clean and consistent design throughout your application.

<?php
echo "<html>
<head>
<style>
.text {
  color: #333;
  font-size: 16px;
}
</style>
</head>
<body>
<p class='text'>This is some styled text output using PHP and CSS.</p>
</body>
</html>";
?>