How can inline styles be avoided in PHP when formatting variables within HTML elements?

To avoid using inline styles when formatting variables within HTML elements in PHP, it is recommended to separate the styling from the content by using classes or external CSS files. This promotes better separation of concerns and makes the code more maintainable and easier to update in the future.

<?php
$variable = "Hello, World!";
?>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
    <div class="styled"><?php echo $variable; ?></div>
</body>
</html>