# Use Whitespace Control Tags

Strip unnecessary whitespace from Liquid output to reduce HTML payload.

```liquid
{% comment %} BAD: extra whitespace in output {% endcomment %}
{% if section.settings.title != blank %}
  <h2>{{ section.settings.title }}</h2>
{% endif %}

{% comment %} GOOD: stripped output {% endcomment %}
{%- if section.settings.title != blank -%}
  <h2>{{ section.settings.title }}</h2>
{%- endif -%}
```

Use `{%-` and `-%}` on control flow tags. Keep `{{` output tags without stripping when the surrounding whitespace is meaningful for layout.

## Exceptions — Never Strip Whitespace On

```liquid
{% comment %} BAD: stripping on comment tags can break surrounding markup {% endcomment %}
{%- comment -%} Hero section {%- endcomment -%}

{% comment %} GOOD: no stripping on comment tags {% endcomment %}
{% comment %} Hero section {% endcomment %}

{% comment %} BAD: stripping on capture breaks output {% endcomment %}
{%- capture hero_class -%}px-24 py-48{%- endcapture -%}

{% comment %} GOOD: no stripping on capture {% endcomment %}
{% capture hero_class %}px-24 py-48{% endcapture %}
```

Do not use `{%-` / `-%}` on `{% comment %}` or `{% capture %}` tags. Also avoid whitespace stripping inside HTML attributes — it can collapse attribute values.
