diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html
index ee62dd613..996fd5422 100644
--- a/sphinx_rtd_theme/layout.html
+++ b/sphinx_rtd_theme/layout.html
@@ -23,10 +23,18 @@
{%- for css in css_files %}
- {%- if css|attr("rel") %}
-
+ {%- if sphinx_version >= "1.8.0" %}
+ {%- if css|attr("filename") %}
+ {{ css_tag(css) }}
+ {%- else %}
+
+ {%- endif %}
{%- else %}
-
+ {%- if css|attr("rel") %}
+
+ {%- else %}
+
+ {%- endif %}
{%- endif %}
{%- endfor %}