---
title: StylesheetTagInWrongFile
description: 'Identifies stylesheet tags outside section, block, and snippet files.'
source_url:
  html: >-
    https://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/stylesheet-tag-in-wrong-file
  md: >-
    https://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/stylesheet-tag-in-wrong-file.md
api_name: liquid
---

# StylesheetTagInWrongFile

Identifies `{% stylesheet %}` tags in files where stylesheet tags aren't valid. Theme Check reports a stylesheet tag unless it's in a section, block, or snippet file.

Shopify bundles the CSS from stylesheet tags in section, block, and snippet files only, so keep these tags out of templates, layouts, and other theme files. For more information, refer to [JavaScript and stylesheet tags](https://shopify.dev/docs/storefronts/themes/best-practices/javascript-and-stylesheet-tags#stylesheet).

***

## Examples

The following examples contain code snippets that either fail or pass this check.

### ✗ Fail

In the following example, `templates/index.liquid` contains a `{% stylesheet %}` tag:

```liquid
{% stylesheet %}
.template-index {
  display: grid;
}
{% endstylesheet %}
```

### ✓ Pass

In the following example, `snippets/card.liquid` is a snippet file, so it can contain a `{% stylesheet %}` tag:

```liquid
{% stylesheet %}
.card {
  display: grid;
}
{% endstylesheet %}
```

***

## Options

The following example contains the default configuration for this check:

```yaml
StylesheetTagInWrongFile:
  enabled: true
  severity: error
```

| Parameter | Description |
| - | - |
| `enabled` | Whether this check is enabled. |
| `severity` | The [severity](https://shopify.dev/docs/storefronts/themes/tools/theme-check/configuration#check-severity) of the check. |

***

## Disabling this check

Disabling this check isn't recommended. If you can't avoid violating the rule, then you should disable the check using the [comment syntax](https://shopify.dev/docs/storefronts/themes/tools/theme-check/configuration#disable-checks-using-liquid-comments). This ensures that you intentionally disable the check for each instance.

```liquid
{% # theme-check-disable StylesheetTagInWrongFile %}
{% stylesheet %}
.template-index {
  display: grid;
}
{% endstylesheet %}
{% # theme-check-enable StylesheetTagInWrongFile %}
```

***
