diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html
index 35c8ddc40..e33c80067 100644
--- a/sphinx_rtd_theme/layout.html
+++ b/sphinx_rtd_theme/layout.html
@@ -42,7 +42,11 @@
{#- FAVICON #}
{%- if favicon %}
+ {%- if sphinx_version_info < (4, 0) -%}
+ {%- else %}
+
+ {%- endif %}
{%- endif -%}
{#- CANONICAL URL (deprecated) #}
@@ -139,7 +143,11 @@
{#- Not strictly valid HTML, but it's the only way to display/scale
it properly, without weird scripting or heaps of work
#}
+ {%- if sphinx_version_info < (4, 0) -%}
+ {%- else %}
+
+ {%- endif %}
{%- endif %}