Title: WP_HTML_Active_Formatting_Elements::remove_node
Published: November 8, 2023
Last modified: February 24, 2026

---

# WP_HTML_Active_Formatting_Elements::remove_node( WP_HTML_Token $token ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_active_formatting_elements/remove_node/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_html_active_formatting_elements/remove_node/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_active_formatting_elements/remove_node/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_active_formatting_elements/remove_node/?output_format=md#changelog)

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

Removes a node from the stack of active formatting elements.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_html_active_formatting_elements/remove_node/?output_format=md#parameters)󠁿

 `$token`[WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)
required

Remove this node from the stack, if it’s there already.

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

 bool Whether the node was found and removed from the stack of active formatting
elements.

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

    ```php
     */
    public function remove_node( WP_HTML_Token $token ) {
    	foreach ( $this->walk_up() as $position_from_end => $item ) {
    		if ( $token->bookmark_name !== $item->bookmark_name ) {
    			continue;
    		}

    		$position_from_start = $this->count() - $position_from_end - 1;
    		array_splice( $this->stack, $position_from_start, 1 );
    		return true;
    	}

    	return false;
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-active-formatting-elements.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php#L138)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php#L138-L150)

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

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.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_active_formatting_elements%2Fremove_node%2F)
before being able to contribute a note or feedback.