Question: Can I put this in my HTML `<head>`?

```
<link rel="stylesheet" href="http://site.com/some/php/script/userid/style.php" />

```

Basically, can I pass a user ID via a URI segment (or a GET variable) to a PHP script - which will still be validly treated as a stylesheet?

So, for example, if in my webapp a user has a custom CSS stylesheet for their page, I can just load it up dynamically in my controller by outputting this as the stylesheet URL - is this possible? I know the PHP part is certainly possible, but will this still be valid or fully browser/server compatible?

Thanks!

Answer: 
I am assuming you're asking "will this work?" and not "is this valid HTML?" for that, See @Gordon's answer.

If your PHP script outputs a `text/css` content type and valid CSS, this will work fine.

```
header("Content-type: text/css");

```

This header is necessary for FF to interpret the CSS. See [here](http://webcache.googleusercontent.com/search?q=cache%3aBOkQyfDxrzcJ%3ahttps://developer.mozilla.org/en/incorrect_mime_type_for_css_files%20firefox%20css%20content%20type%20mdc&cd=1&hl=de&ct=clnk&gl=de&source=www.google.de) why.

It will be desirable to add some caching headers as well, otherwise the resource will probably be requested on every page load.

**However...**

If you need to output dynamic CSS, consider having a static style sheet (i.e. one that does **not** get interpreted by PHP) with all the generic stuff, and adding dynamic data in the document's head:

```
<link rel="stylesheet" href="http://site.com/resources/style.css" />

<style type="text/css">
  .userText { color: <?php echo $userTextColor; `> }
  etc. etc. 
</style>

```

this way, the CSS resource can remain a static file. It will not require starting a PHP process to get served. If your CSS parameters change from page to page, this will save you a HTTP request.
as long as you have correct headers set, there should not be any problems with that.