# css()

Creates one or multiple CSS link tags

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/helpers.php#L93>

****

```php
css(string|array $url, string|array|null $options = null): string|null
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$url` (required) | `string` or `array` | – | Relative or absolute URLs, an array of URLs or `@auto` for automatic template css loading |
| `$options` | `string`, `array` or `null` | `null` | Pass an array of attributes for the link tag or a media attribute string |

## Return types

`string` or `null`

## Examples

### Creating a single link tag

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

### Creating multiple link tags

```php
<?= css([
  'assets/css/site.css',
  'assets/css/form.css',
  'assets/css/grid.css'
]) ?>
```

### Autoloading template specific css files

```php
<?= 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:

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

### Other attributes

You can also pass an array of completely custom attributes:

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

For the `rel` attribute only `alternate stylesheet` is a valid value, and only if also passing a `title` attribute:

```php
<?= css('assets/css/high-contrast.css', ['rel' => 'alternate stylesheet', 'title' => 'High contrast']) ?>
```