Skip to content
Advertisement

How to link CSS with PHP?

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:

JavaScript

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`:

JavaScript

Any help would be greatly appreciated.

Advertisement

Answer

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:

JavaScript

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

style.css:

JavaScript

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

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement