1

I'm beginning to do HTML, CSS and PHP and I can't have a clear cut answer on how to add CSS to my existing PHP file:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style_conjugate.php" media="screen" /> 
</head>

<body>
    <?php
        $arr verbs = [
            verbs
        ];

        $arr base verbs= [
            base verbs
        ];



        for ($i = 0; $i < $max.baseverbs; $i++)
        {
            foreach (verbs as pronoun => conjugation) 
            {
                echo
            }
            echo for linebreak
        }   

    ?>
</body>
</html>

I would like the verbs to be displayed in blue, which needs tobe done in PHP, according to what I have read, however I can't get it to work.

I can't seem to specify how the colour should be changed in the php script`:

php.conjugation
{
  blue color
}

Any help would be greatly appreciated.

1
  • What's your exact question? Why not style the outputted HTML like usual HTML? Commented Jul 23, 2020 at 14:55

2 Answers 2

2

You are specifying your CSS file to be a "text/css", however you are linking to a .php file.

You need to firstly create a new stylesheet (CSS File) with the .css extension. Create a file called style.css in your directory and link it into your PHP file with the following:

<link rel="stylesheet" type="text/css" href="style.css" />

The contents of your stylesheet should contain the following class which you can use to get blue text:

style.css:

.text-blue {
    color: blue;
}

Now you can use this CSS class in your PHP echo to apply the color blue on the $conjugation variable:

foreach ($arr_pronoun_to_conjugation as $pronoun => $conjugation) 
{
    echo "$pronoun " . $arr_verbstem[$i] . " <div class='text-blue'>$conjugation</div><br>";
}
Sign up to request clarification or add additional context in comments.

Comments

0

you might have missed to include below line into your style.php file.

header("Content-type: text/css; charset: UTF-8");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.