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: 
Yes, this is valid HTML. For the validity of the HTML document, the only thing that's important is that the [href attribute points to a URI.](http://www.w3.org/TR/xhtml1/dtds.html) 

```
<!ELEMENT link EMPTY>
<!ATTLIST link
  %attrs;
  charset     %Charset;      #IMPLIED
  href        %URI;          #IMPLIED
  hreflang    %LanguageCode; #IMPLIED
  type        %ContentType;  #IMPLIED
  rel         %LinkTypes;    #IMPLIED
  rev         %LinkTypes;    #IMPLIED
  media       %MediaDesc;    #IMPLIED
  >

```

You can check the validity of your document with <http://validator.w3.org/check>

### But …

The script that is located at that URI has to serve any content with the correct header so the **browser** can actually interpret it as CSS. This is a completely different thing than HTML validity though. So for serving a CSS file, you have to set the text/css header.

Note that using this approach is generally discouraged though [unless you implement some sort of caching mechanism](http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php). When you point to a PHP file, the webserver will execute the PHP file so you lose any caching mechanism you'd usually have for static resources.
As long as you output proper CSS it fine. Your browser doesn't care how the stylesheet is generated or how the URI looks like. It just has to be a stylesheet.