diff --git a/src/Renderer.php b/src/Renderer.php
index 48bc491..6508cec 100644
--- a/src/Renderer.php
+++ b/src/Renderer.php
@@ -31,6 +31,17 @@ class Renderer extends CoreRenderer {
       return '';
     }
 
+    // W3C documentation: HTML Comments are markup,
+    // thus it's not allowed to use HTML Comments inside HTML element attributes.
+    // Example: <a <!--title="need to be comment out"-->>a link</a> is as wrong as <a <span></span>>a link</a>.
+    // Following condition is applied to avoid breaking HTML structure.
+    // In result elements that are used as string value of the parent element attribute are skipped.
+    // (Example, `form_token` value).
+    if ($result == strip_tags($result)) {
+      // Returned without debug output.
+      return $result;
+    }
+
     // Apply the same default cacheability logic that Renderer::doRender()
     // applies.
     $pre_bubbling_elements = $original_elements;
