Title: Why not put CSS into .php
Last modified: August 18, 2016

---

# Why not put CSS into .php

 *  [idbehold](https://wordpress.org/support/users/idbehold/)
 * (@idbehold)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/)
 * Why doesn’t WordPress do this by default? If you just put the CSS into a php 
   file, you could style really easily. It would be like programming a style instead
   of just telling the browser exactly how everything should be styled, you can 
   let your server do some of the work.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175803)
 * In my opinion, having the CSS separate is better from a learner’s standpoint.
   There have been some themes which combine CSS in the PHP file, but the going 
   trend is to keep the two separate. Basically, if you want to edit a certain field’s
   font size in sidebar.php, take a look at what class it is, and find it in style.
   css. This method is also recommended by most of the tutorials, Universities, 
   training groups, etc.
 *  [fuzzy_logic](https://wordpress.org/support/users/fuzzy_logic/)
 * (@fuzzy_logic)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175811)
 * I don’t think any professional websites put the CSS styles in the html file, 
   unless it’s to override the stylesheet.
 *  [alexkingorg](https://wordpress.org/support/users/alexkingorg/)
 * (@alexkingorg)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175813)
 * Putting the CSS into a .php file is actually a very easy way to implement different
   color schemes – make the colors PHP variables and load a set of variables for
   each color scheme.
 *  [jodpie](https://wordpress.org/support/users/jodpie/)
 * (@jodpie)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175817)
 * Separating CSS from HTML is the common rule “unless it’s to override the stylesheet”
   as _fuzzy\_logic_ stated. As HTML is dynamically generated in example with PHP,
   why not the same for CSS?
 * The following PHP code is to provide an external CSS to any HTML page:
 * `
    header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-
   revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("
   Content-Description: File Transfer"); header("Content-Transfer-Encoding: text");
   header("Content-Type: text/css");
 *  [Noemi Nozze](https://wordpress.org/support/users/mcmike/)
 * (@mcmike)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175820)
 * If you work with Themes like wordpress I think (imho) that you really want seperate
   CSS files also because there are so many places of putting your different layout
   classes / ID’s etc.etc.
 * Besides that if you want PHP-CSS I don’t see the real use of it, just makes things
   more complicated for people who do not understand PHP.
 * When a file is named .php people already are scared of it contents…

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Why not put CSS into .php’ is closed to new replies.

 * 5 replies
 * 6 participants
 * Last reply from: [Noemi Nozze](https://wordpress.org/support/users/mcmike/)
 * Last activity: [21 years, 2 months ago](https://wordpress.org/support/topic/why-not-put-css-into-php/#post-175820)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
