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

---

# WP_HTML_Processor::step_initial(): bool

## In this article

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

This function’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.

Parses next element in the ‘initial’ insertion mode.

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

This internal function performs the ‘initial’ insertion mode logic for the generalized
[WP_HTML_Processor::step()](https://developer.wordpress.org/reference/classes/wp_html_processor/step/)
function.

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

 * [https://html.spec.whatwg.org/#the-initial-insertion-mode](https://html.spec.whatwg.org/#the-initial-insertion-mode/)
 * [WP_HTML_Processor::step](https://developer.wordpress.org/reference/classes/WP_HTML_Processor/step/)

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

 bool Whether an element was found.

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

    ```php
    		isset( $serialized_attribute_name[0] ) &&
    		'=' === $serialized_attribute_name[0]
    	) {
    		$html .= '=""';
    	}

    	$html .= " {$serialized_attribute_name}";
    	$value = $this->get_attribute( $attribute_name );

    	if ( is_string( $value ) ) {
    		$html .= '="' . self::escape_text_for_serialization( $value ) . '"';
    	}

    	$previous_attribute_was_true = true === $value;
    }

    if ( ! $in_html && $this->has_self_closing_flag() ) {
    	$html .= ' /';
    }

    $html .= '>';

    /*
     * The HTML parser strips a leading newline immediately after the start
     * tag of TEXTAREA, PRE, and LISTING elements in HTML content. When serializing,
     * prepend a leading newline to ensure the semantic HTML content is preserved.
     *
     * For example, `<pre>\n\nX</pre>` must not become `<pre>\nX</pre>` because its content
     * has changed. However, `<pre>X</pre>` and `<pre>\nX</pre>` are _equivalent_.
     *
     * > A start tag whose tag name is "textarea"
     * >   …
     * >   If the next token is a U+000A LINE FEED (LF) character token, then ignore
     * >   that token and move on to the next one. (Newlines at the start of textarea
     * >   elements are ignored as an authoring convenience.)
     *
     * > A start tag whose tag name is one of: "pre", "listing"
     * >   …
     * >   If the next token is a U+000A LINE FEED (LF) character token, then ignore
     * >   that token and move on to the next one. (Newlines at the start of pre blocks
     * >   are ignored as an authoring convenience.)
     *
     * @see https://html.spec.whatwg.org/multipage/parsing.html
     */
    if ( $in_html && ( 'TEXTAREA' === $tag_name || 'PRE' === $tag_name || 'LISTING' === $tag_name ) ) {
    	$html .= "\n";
    }

    // Flush out self-contained elements.
    if ( $in_html && in_array( $tag_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) {
    	$text = $this->get_modifiable_text();

    	switch ( $tag_name ) {
    		case 'IFRAME':
    		case 'NOEMBED':
    ```

[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/7.1/src/wp-includes/html-api/class-wp-html-processor.php#L1455)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/html-api/class-wp-html-processor.php#L1455-L1509)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_html_processor/step_initial/?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%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_html_processor%2Fstep_initial%2F)
before being able to contribute a note or feedback.