Title: WP_HTML_Tag_Processor::has_self_closing_flag
Published: August 8, 2023
Last modified: August 20, 2026

---

# WP_HTML_Tag_Processor::has_self_closing_flag(): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#changelog)

Indicates if the currently matched tag contains the self-closing flag.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#description)󠁿

No HTML elements ought to have the self-closing flag and for those, the self-closing
flag will be ignored. For void elements this is benign because they “self close”
automatically. For non-void HTML elements though problems will appear if someone
intends to use a self-closing element in place of that element with an empty body.

For HTML foreign elements and custom elements the self-closing flag determines if
they self-close or not.

This function does not determine if a tag is self-closing, but only if the self-
closing flag is present in the syntax.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#return)󠁿

 bool Whether the currently matched tag contains the self-closing flag.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#source)󠁿

    ```php
    public function has_self_closing_flag(): bool {
    	if ( self::STATE_MATCHED_TAG !== $this->parser_state ) {
    		return false;
    	}

    	return $this->has_self_closing_flag;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-tag-processor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/html-api/class-wp-html-tag-processor.php#L3484)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/html-api/class-wp-html-tag-processor.php#L3484-L3490)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_HTML_Processor::has_self_closing_flag()](https://developer.wordpress.org/reference/classes/wp_html_processor/has_self_closing_flag/)`wp-includes/html-api/class-wp-html-processor.php` |

Indicates if the currently matched tag contains the self-closing flag.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/has_self_closing_flag/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_html_tag_processor%2Fhas_self_closing_flag%2F)
before being able to contribute a note or feedback.