Documentation > Services API > ServicesOutput > RenderCSSLink(String,String,String,String,OutputContext)
RenderCSSLink
For creating links to CSS assets. Accepts an asset path and if loaded, renders a link to it as an HTML link element. Use as a convenience function when building wrapper templates and anywhere you need to load a css asset in output.
public System.String RenderCSSLink(String,String,String,String,OutputContext)
Returns
String containing HTML code for loading a CSS Asset.
Parameters
| Name | Description | Type |
|---|---|---|
| cssPath | The Asset Path of the CMS Asset that contains the CSS code. | System.String |
| mediaType | Optional mediatype. | System.String |
| cssIdAttribute | Optional html ID attribute for css link. | System.String |
| qString | Optional query string appended to css link. | System.String |
| context | Optional current OutputContext for checking the publishing status. | CrownPeak.CMSAPI.OutputContext |
Code Example
C#
Sample:
Out.WriteLine(ServicesOutput.RenderCSSLink(cssPath, context: context));
/*returns and outputs:
<link rel="stylesheet" type="text/css" href="[[cssAsset publishing path or cms path]]?" */
string cssPath = "/SAMPLE Pharmaceutical/_Assets/css/style.css";
Out.WriteLine( ServicesOutput.RenderCSSLink(cssPath, mediaType: "print", cssIdAttribute:"myCssIdAttribute", qString: "myQString", context: context) );
/*returns and outputs:
<link rel="stylesheet" type="text/css" href="[[cssAsset publishing path or cms path]]?myQString" media="print" id="myCssIdAttribute" />
assuming both the css and the containing/wrapping assets are in publishing states.*/