hgbso
hgbso

Reputation: 131

PHP using a to css style a php file

is there a way to style a php file with css so I can use border,padding, align and teother various

will this work or not if i added to the php or will i need functions for using this

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

Upvotes: 1

Views: 3807

Answers (5)

liamfriel
liamfriel

Reputation: 107

If you are looking for a way to define styles in variables i.e. colour etc and make it easier to generate css try http://lesscss.org/

It's what I use to make css edits faster instead of copying and pasting.

Upvotes: -1

Thariama
Thariama

Reputation: 50832

  1. You cannot and probably will never be able to style a PHP file using css. What you want to style using css is the html content created using PHP and/or javascript! That is because styling takes place on the client machine in order to show things to the user while php gets executed on the server machine in orderf to produce code which will be readable by a browser.

  2. <link rel="stylesheet" type="text/css" href="style.css" /> will work if the file style.css is found at that location (i assume your are using valid css definitions in your file)

Upvotes: 6

deceze
deceze

Reputation: 522076

PHP doesn't know or care about CSS, and neither does it need to.
PHP runs on the server and does whatever it does, which should result in an HTML document.
This HTML document is send to the browser.
Only the browser cares about CSS, and it doesn't care whether an HTML document was just a file on the server's hard disk or whether it was created by PHP or magic fairies.


If the document the browser receives is an HTML document, you can use CSS with it. PHP has absolutely zero influence on this.

Upvotes: 4

Elzo Valugi
Elzo Valugi

Reputation: 27866

You can use css to style HTML files. PHP generates HTML (or not) and you cannot style PHP files.

Upvotes: 4

BoltClock
BoltClock

Reputation: 723598

You don't style PHP with CSS. What's there to style? It's all just server-side code that generates HTML. You style HTML with CSS, not PHP.

Upvotes: 3

Related Questions