<p>It looks like you should be able to wrap it in an <code>if</code> statement like this...  </p>

<pre><code>{% set pageCss %}
    {{ entry.inlineCss }}
{% endset %}

{% if pageCss != ''  %}
    {% includeCss pageCss %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2016-03-03T16:54:42.250Z
2016-03-03T16:54:42.250Z
Steve Holland
<p>I have created a field named inlineCss, which i'm using to set a pageCss variable. However, when no CSS is added to the entry, the <code>{% includeCss pageCss %}</code> is still adding a style tag in the head, albeit empty.</p>

<pre><code>{% set pageCss %}
    {{ entry.inlineCss }}
{% endset %}

{% includeCss pageCss %}
</code></pre>

<p>Is there a way to only show the style tag if the pageCss variable is not empty?</p>

<p>I've tried checking for is defined and not null but it just keeps outputting the empty style tag.</p>

<variable>
Check if includeCss set
# Check if includeCss set

(Asked by: username_0 on 2016-03-03)

I have created a field named inlineCss, which i'm using to set a pageCss variable. However, when no CSS is added to the entry, the {% includeCss pageCss %} is still adding a style tag in the head, albeit empty.
{% set pageCss %}
    {{ entry.inlineCss }}
{% endset %}

{% includeCss pageCss %}

Is there a way to only show the style tag if the pageCss variable is not empty?
I've tried checking for is defined and not null but it just keeps outputting the empty style tag.

**Tags:** variable


---

## 1 answers

### Answer by username_1 on 2016-03-03. Score: 3

It looks like you should be able to wrap it in an if statement like this...  
{% set pageCss %}
    {{ entry.inlineCss }}
{% endset %}

{% if pageCss != ''  %}
    {% includeCss pageCss %}
{% endif %}


---

