--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -717,6 +717,9 @@
 
   // Add comment author user ID. Necessary for the comment-by-viewer library.
   $variables['attributes']['data-comment-user-id'] = $comment->getOwnerId();
+
+  // Add comment ID. 
+  $variables['comment_id'] = $comment->id();
 }
 
 /**
--- a/core/modules/comment/src/CommentViewBuilder.php
+++ b/core/modules/comment/src/CommentViewBuilder.php
@@ -176,7 +176,7 @@
       }
 
       // Add anchor for each comment.
-      $prefix .= "<a id=\"comment-{$comment->id()}\"></a>\n";
       $build['#prefix'] = $prefix;
 
       // Close all open divs.
--- a/core/modules/comment/templates/comment.html.twig
+++ b/core/modules/comment/templates/comment.html.twig
@@ -67,7 +67,7 @@
  */
 #}
 
-<article{{ attributes.addClass('js-comment') }}>
+<article{{ attributes.addClass('js-comment') }} id="comment-{{ comment_id }}">
   {#
     Hide the "new" indicator by default, let a piece of JavaScript ask the
     server which comments are new for the user. Rendering the final "new"
--- a/core/themes/bartik/templates/comment.html.twig
+++ b/core/themes/bartik/templates/comment.html.twig
@@ -5,6 +5,7 @@
  *
  * Available variables:
  * - author: Comment author. Can be a link or plain text.
+ * - comment_id: Comment id.
  * - content: The content-related items for the comment display. Use
  *   {{ content }} to print them all, or print a subset such as
  *   {{ content.field_example }}. Use the following code to temporarily suppress
@@ -77,7 +78,7 @@
     'clearfix',
   ]
 %}
-<article role="article"{{ attributes.addClass(classes)|without('role') }}>
+<article role="article"{{ attributes.addClass(classes)|without('role') }} id="comment-{{ comment_id }}">
   {#
     Hide the "new" indicator by default, let a piece of JavaScript ask the
     server which comments are new for the user. Rendering the final "new"
