Title: WP_HTML_Processor::get_namespace
Published: February 24, 2026

---

# WP_HTML_Processor::get_namespace(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_html_processor/get_namespace/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_processor/get_namespace/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_html_processor/get_namespace/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_html_processor/get_namespace/?output_format=md#wp--skip-link--target)

Indicates the namespace of the current token, or “html” if there is none.

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

 string One of "html", "math", or "svg".

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

    ```php
    public function get_namespace(): string {
    	if ( ! isset( $this->current_element ) ) {
    		return parent::get_namespace();
    	}

    	return $this->current_element->token->namespace;
    }
    ```

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

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

| Uses | Description | 
| [WP_HTML_Tag_Processor::get_namespace()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/get_namespace/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Returns the namespace of the matched token.

  |

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

Serializes the currently-matched token.

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

Indicates if the currently-matched node expects a closing token, or if it will self-close on the next step.

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

Returns the uppercase name of the matched tag.

  |

## User Contributed Notes

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