Skip to content
PHP Logo

How can CSS be used to enhance the display of formatted text in PHP?

To enhance the display of formatted text in PHP using CSS, you can create a separate CSS file with styles for different text elements such as headings, paragraphs, lists, etc. Then, include this CSS file in your PHP file using the <link> tag within the <head> section. This will allow you to easily apply styles to your formatted text without cluttering your PHP code with inline styles.

php
<!DOCTYPE html>
<html>
<head>
    <title>Formatted Text with CSS</title>
    <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
    <h1>This is a Heading</h1>
    <p>This is a paragraph of text.</p>
    <ul>
        <li>List item 1</li>
        <li>List item 2</li>
        <li>List item 3</li>
    </ul>
</body>
</html>