How can I highlight PHP in a *.css file?

I've a CSS file which also includes PHP directives with <? and ?>.

I cannot change the extension (framework requirement) but still would like to get PHP detection.

For me currently it's not just the benefit of having syntax highlighting but also of having the PHP blocks being marked as errors in CSS.

I'm using 7.1.3


1 comment
Comment actions Permalink

Hi there,

Yes, you can do this .. but this requires changing some IDE-wide settings that would affect ALL projects unless you can have unique file name pattern.

1) So .. if you can -- give such files some complex extension (e.g. "*.php.css"). This is just to have some unique file name pattern.


  • If you did #1 -- assign such pattern to "PHP Files" file type in "Settings | File Types".
  • If not -- you have to re-assign "*.css" pattern from "CSS files" to "PHP files". Only files that will be associated with "PHP files" will have PHP support. Remember -- this affects ALL projects.

3) "Settings | Template Data Language" -- find your file(s) or whole folder(s) and assign "CSS" in the right column to them.


Please sign in to leave a comment.