How can the output in PHP, such as temperature readings, be formatted and centered within an HTML page?
To format and center output in PHP within an HTML page, you can use CSS styles to center the text and format it as needed. You can create a CSS class that centers the text and then apply that class to the output in your PHP code.
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
}
</style>
</head>
<body>
<?php
$temperature = 25;
echo '<div class="center">Temperature: ' . $temperature . '°C</div>';
?>
</body>
</html>
Keywords
Related Questions
- What recommendations can be made to optimize PHP code for varying screen resolutions and ensure a consistent user experience across different devices?
- How can PHP scripts be used to securely handle file access from external servers?
- How can PHP beginners effectively troubleshoot and debug issues with database queries?