css($path, $media = null)

Creates one or multiple CSS link tags

  • $path (string)
    Relative or absolute URL
  • $media (string|array)
    CSS media value or an array of attributes
  • return (string)

Example

Creating a single link tag

<?= css('assets/css/site.css') ?>

Creating multiple link tags

<?= css(array(
  'assets/css/site.css',
  'assets/css/form.css',
  'assets/css/grid.css'
)) ?>

Autoloading template specific css files

<?= css('@auto') ?>

Template specific css files must be located in /assets/css/templates and named like the template.

Template CSS file
/site/templates/project.php /assets/css/templates/project.css
/site/templates/home.php /assets/css/templates/home.css
/site/templates/blog.php /assets/css/templates/blog.css

Media attribute

You can also specify a media attribute for the link tags:

<?= css('assets/css/print.css', 'print') ?>

2.5.2 +

Other attributes

You can also pass an array of completely custom attributes:

<?= css('assets/css/print.css', ['media' => 'print', 'data-something' => 'my-value']) ?>