Title: WP_HTML_Open_Elements::clear_to_table_row_context
Published: February 24, 2026

---

# WP_HTML_Open_Elements::clear_to_table_row_context()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#see-also)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#changelog)

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

Clear the stack back to a table row context.

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

> When the steps above require the UA to clear the stack back to a table row context,
> it means that the UA must, while the current node is not a tr, template, or html
> element, pop elements from the stack of open elements.

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_html_open_elements/clear_to_table_row_context/?output_format=md#see-also)󠁿

 * [https://html.spec.whatwg.org/multipage/parsing.html#clear-the-stack-back-to-a-table-row-context](https://html.spec.whatwg.org/multipage/parsing.html#clear-the-stack-back-to-a-table-row-context/)

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

    ```php
    public function clear_to_table_row_context(): void {
    	foreach ( $this->walk_up() as $item ) {
    		if (
    			'TR' === $item->node_name ||
    			'TEMPLATE' === $item->node_name ||
    			'HTML' === $item->node_name
    		) {
    			break;
    		}
    		$this->pop();
    	}
    }
    ```

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

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

| Uses | Description | 
| [WP_HTML_Open_Elements::walk_up()](https://developer.wordpress.org/reference/classes/wp_html_open_elements/walk_up/)`wp-includes/html-api/class-wp-html-open-elements.php` |

Steps through the stack of open elements, starting with the bottom element (added last) and walking upwards to the one added first.

  | 
| [WP_HTML_Open_Elements::pop()](https://developer.wordpress.org/reference/classes/wp_html_open_elements/pop/)`wp-includes/html-api/class-wp-html-open-elements.php` |

Pops a node off of the stack of open elements.

  |

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

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