In regular old HTMl we are allowed to do the following to use a css file depending on browser versions:

<link rel="stylesheet" href="path-to-styles/css/cssfilename.css">
<!--[if IE 7]>
<link rel="stylesheet" href="path-to-styles/css/cssfilename.css">

in a sharepoint user control we can add the files like so:

 <SharePoint:CssRegistration name="/_layouts/solutionfolder/filename.css" After="corev4.css" runat="server"/> 

How can I determine which version of the style sheet to load based on browser version? Or do I register them all then later determine which to use


You can use ConditionalExpression property to specify your conditional browser version.

For ex.

<SharePoint:CSSRegistration name="/_layouts/solutionfolder/filename.css" After="corev4.css" ConditionalExpression="lt IE 7" runat="server" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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