Additional parameter for "registerCssFile"

Ofter you need to add a browser specific css - e.g. for our friend, the IE6. So I was looking for a "conditional" parameter.

instead of:

public void registerCssFile(string $url, string $media='')

I’d request a third parameter:

public void registerCssFile(string $url, string $media='', string $condition='')

so this:

Yii::app()->clientScript->registerCssFile('/css/ie.css', 'screen, projection', 'lt IE 8');

would produce this:

<!--[if lt IE 8]>

    <link rel="stylesheet" type="text/css" href="/css/ie.css" media="screen, projection" />


Good idea! I was searching for this option as well. At this moment it seems not possible to use registerCssFile for a browser specific css and sometimes you just need that. May I suggest to add this third parameter to the registerScriptFile function as well.

Very good, I need it

I’m very impatient that future will be integrated in the yii distrib

This is just what I was looking for. I’d love to see this in Yii.

Hi samdark,

how to use conditional classes in <html> tag in case we use a third party library?


<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.css">

<!–[if IE 7]>

<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome-ie7.css">


We shouldn’t merge font-awesome-ie7.css to font-awesome.css because it hard to migrate to new version

If the library is used sitewide as font awesome, you can paste it as HTML in layout file.

Thank for your feedback but i think it will more flexible if we have an option to allow insert prefix and suffix for each Css/Javascript file (IE condition or comment for example)

Probably. Please create an issue at github and we’ll look into it. Can’t promise that it will be solved and solved fast though. Thanks.