diff --git a/lib/experimental/html/class-wp-html-tag-processor.php b/lib/experimental/html/class-wp-html-tag-processor.php
index 22ff19a5e0f162..e50cb3d43f76ea 100644
--- a/lib/experimental/html/class-wp-html-tag-processor.php
+++ b/lib/experimental/html/class-wp-html-tag-processor.php
@@ -1430,7 +1430,7 @@ public function get_attribute( $name ) {
* @return array|null List of attribute names, or `null` if not at a tag.
*/
function get_attribute_names() {
- if ( null === $this->tag_name_starts_at ) {
+ if ( $this->is_closing_tag || null === $this->tag_name_starts_at ) {
return null;
}