How can CSS be used to address formatting problems when outputting HTML with PHP?
When outputting HTML with PHP, formatting can sometimes be inconsistent or difficult to control. CSS can be used to address these formatting problems by applying styles to the HTML elements generated by PHP. By using CSS, you can easily control the layout, colors, fonts, and spacing of the outputted HTML content.
<?php
echo '<html>
<head>
<style>
/* CSS styles to address formatting problems */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
h1 {
color: #333;
text-align: center;
}
p {
margin: 10px;
}
</style>
</head>
<body>
<h1>Welcome to our website!</h1>
<p>This is some sample text generated by PHP.</p>
</body>
</html>';
?>