Title: WP_HTML_Span
Published: March 29, 2023
Last modified: February 24, 2026

---

# class WP_HTML_Span {}

## In this article

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

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

This class’s access is marked private. This means it is not intended for use by 
plugin or theme developers, only by core. It is listed here for completeness.

Core class used by the HTML tag processor to represent a textual span inside an 
HTML document.

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

This is a two-tuple in disguise, used to avoid the memory overhead involved in using
an array for the same purpose.

This class is for internal usage of the [WP_HTML_Tag_Processor](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/)
class.

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

 * [WP_HTML_Tag_Processor](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/)

## 󠀁[Methods](https://developer.wordpress.org/reference/classes/wp_html_span/?output_format=md#methods)󠁿

| Name | Description | 
| [WP_HTML_Span::__construct](https://developer.wordpress.org/reference/classes/wp_html_span/__construct/) | Constructor. |

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

    ```php
    class WP_HTML_Span {
    	/**
    	 * Byte offset into document where span begins.
    	 *
    	 * @since 6.2.0
    	 *
    	 * @var int
    	 */
    	public $start;

    	/**
    	 * Byte length of this span.
    	 *
    	 * @since 6.5.0
    	 *
    	 * @var int
    	 */
    	public $length;

    	/**
    	 * Constructor.
    	 *
    	 * @since 6.2.0
    	 *
    	 * @param int $start  Byte offset into document where replacement span begins.
    	 * @param int $length Byte length of span.
    	 */
    	public function __construct( int $start, int $length ) {
    		$this->start  = $start;
    		$this->length = $length;
    	}
    }
    ```

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

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

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Replaced `end` with `length` to more closely align with `substr()`. | 
| [6.2.0](https://developer.wordpress.org/reference/since/6.2.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_span%2F)
before being able to contribute a note or feedback.