Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

conditional css

Go to End

7 Posts   5133 Views


Community Member, 9 Posts

17 April 2008 at 4:31pm

another newbie question :/ where can I add conditional css ? im working on my first SS website, using higherground theme, and it doesn't seem to be right in IE..


Community Member, 149 Posts

17 April 2008 at 6:02pm

Hello, irka!
You can add the conditional css in the templates/ file, just as it's done in the default Blackcandy theme


Community Member, 9 Posts

18 April 2008 at 7:49am

thank you :) sorted this problem anyway,,and thanks for the theme :)

Shane Garelja

Community Member, 18 Posts

22 April 2008 at 2:34pm

Another, "better"(?) but slightly more complicated method I've found for doing this is to add your CSS via the Requirements::css static method in your page controller - you can achieve the same results as conditional statements like so:

function init() {			
    Requirements::css( project() . "/css/default.css");		
    if($pos = strpos( $_SERVER[ 'HTTP_USER_AGENT' ], 'MSIE' ) ) {		
      Requirements::css( project() . "/css/ie.css");		
      $version = substr( $_SERVER[ 'HTTP_USER_AGENT' ], $pos + 5, 3 );
      if( $version < 7 ) {
        Requirements::css( project() . "/css/ie6.css");
      if( $version < 6 ) {
        Requirements::css( project() . "/css/ie5.css");

(You would add this to the Page_Controller class in your mysite/Page.php file)

The advantage here is that you can create page types that extend the Page class and they will automatically pick up the inherited CSS files. You could then then add additional, custom stylesheets for a specific page type if you wanted.


Forum Moderator, 5523 Posts

22 April 2008 at 8:38pm

Handy method. You should add this to the CSS page in the documentation - for other peoples reference


Community Member, 37 Posts

7 May 2008 at 11:48am

Edited: 07/05/2008 11:56am

You can also place this in the Page_Controller function init() and lose the hard coded entries in

Requirements::insertHeadTags("<!--[if IE 6]><style type='text/css'>@import url(themes/" . SSViewer::current_theme() . "/css/ie6.css);</style><![endif]-->");

Requirements::insertHeadTags("<!--[if IE 7]><style type='text/css'>@import url(themes/" . SSViewer::current_theme() . "/css/ie7.css);</style><![endif]-->");

iON creative

Community Member, 42 Posts

29 September 2008 at 6:02pm

Hi there - I found I *had* to add the conditional comments into the Page_Controller function in order to achieve the right hierarchy for the conditional stylesheets, using the BlackCandy theme.

When I included the conditional stylesheets in they were included *before* the layout.css file, which then over-wrote some of my fixes.

Hope this helps someone!