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

---

# WP_HTML_Open_Elements::at( int $nth ): 󠀁[WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)󠁿|null

## In this article

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

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

Returns the name of the node at the nth position on the stack of open elements, 
or `null` if no such position exists.

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

Note that this uses a 1-based index, which represents the “nth item” on the stack,
counting from the top, where the top-most element is the 1st, the second is the 
2nd, etc…

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

 `$nth`intrequired

Retrieve the nth item on the stack, with 1 being the top element, 2 being the second,
etc…

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

 [WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)
|null Name of the node on the stack at the given location, or `null` if the location
isn’t on the stack.

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

    ```php
    public function at( int $nth ): ?WP_HTML_Token {
    	foreach ( $this->walk_down() as $item ) {
    		if ( 0 === --$nth ) {
    			return $item;
    		}
    	}

    	return null;
    }
    ```

[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#L119)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/html-api/class-wp-html-open-elements.php#L119-L127)

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

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

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

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/at/?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%2Fat%2F)
before being able to contribute a note or feedback.