I am trying to use a conditional CssRegistration command in SharePoint 2010, but is not working. Here is the command I am using:

<SharePoint:CssRegistration ID="CssRegister1" name="<% $SPUrl:~SiteCollection/Style Library/nh/css/ie8.css %>" After="main.css" runat="server" ConditionalExpression="IE 8"/>

The css file I want to load is in the style library as indicated. I have approved the master page that I have included this command on. I would like to have my conditional style sheet load after my main.css that is why I am using the After property.

The result is that no include line is appearing the generated html. What am I doing wrong?

1 Answer 1


Use below mentioned code.

<SharePoint:CSSRegistration Name="<% $SPUrl:~SiteCollection/Style Library/nh/css/ie8.css %>" After="main.css" ConditionalExpression="gte IE 7" runat="server" />

You need to change ConditionalExpression="IE 8" to ConditionalExpression="gte IE 7" as I have mentioned above.

  • Also Please check the path of CSS if it is fine or not.

Pay special attention to the ConditionalExpression which is set to NON IE Browser, to reach other browsers you need to also specify the RevealToNonIE="True"

If you still have a problem than please let me know.

  • I can see only ID parameter you have removed from solution code, there is not change in the path
    – Gaurravs
    Commented Dec 29, 2015 at 9:52
  • I have just changed the Conditional Expression as sometimes it is causing the problems...Check it again Dude..
    – Hardik
    Commented Dec 29, 2015 at 9:56
  • ohh My miss. sorry
    – Gaurravs
    Commented Dec 29, 2015 at 10:23
  • Your suggested solution worked in loading the css file now, the only issue is that it is loading it before the main.css. It looks like the After command is being ignored. Any idea how to fix that part?
    – user5013
    Commented Dec 29, 2015 at 16:45
  • In which browser are you facing this issue?
    – Hardik
    Commented Dec 30, 2015 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.