Skip to content

View Helpers

styleSheetLinkTag()

styleSheetLinkTag() — returns string

Available in: controller Category: Asset Functions

Generates one or more <link> tags for including CSS stylesheets in your application. By default, it looks in the publicstylesheets folder of your app but can also handle external URLs or place stylesheets directly in the <head> section when needed.

NameTypeRequiredDefaultDescription
sourcesstringnoThe name of one or many CSS files in the stylesheets folder, minus the .css extension. Pass a full URL to generate a tag for an external style sheet. Can also be called with the source argument.
typestringnotext/cssThe type attribute for the link tag.
mediastringnoallThe media attribute for the link tag.
relstringnoThe rel attribute for the relation between the tag and href.
headbooleannofalseSet to true to place the output in the head area of the HTML page instead of the default behavior (which is to place the output where the function is called from).
delimstringno,The delimiter to use for the list of CSS files.
encodebooleannotrueEncode URL parameters using EncodeForURL(). Please note that this does not make the string safe for placement in HTML attributes, for that you need to wrap the result in EncodeForHtmlAttribute() or use linkTo(), startFormTag() etc instead.
<!--- view code --->
<head>
    <!--- Includes `public/stylesheets/styles.css` --->
    #styleSheetLinkTag("styles")#
    <!--- Includes `public/stylesheets/blog.css` and `public/stylesheets/comments.css` --->
    #styleSheetLinkTag("blog,comments")#
    <!--- Includes printer style sheet --->
    #styleSheetLinkTag(sources="print", media="print")#
    <!--- Includes external style sheet --->
    #styleSheetLinkTag("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/cupertino/jquery-ui.css")#
</head>

<body>
    <!--- This will still appear in the `head` --->
    #styleSheetLinkTag(sources="tabs", head=true)#
</body>