diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php
index 0525ae792a..449098dd62 100644
--- a/src/wp-includes/category-template.php
+++ b/src/wp-includes/category-template.php
@@ -1353,7 +1353,7 @@ function get_the_term_list( $post_id, $taxonomy, $before = '', $sep = '', $after
 		if ( is_wp_error( $link ) ) {
 			return $link;
 		}
-		$links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
+		$links[] = '<a class="' . esc_attr( sanitize_html_class( $taxonomy ) ) . ' ' . esc_attr( sanitize_html_class( $term->slug ) ) . '" href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
 	}
 
 	/**
