Title: WP_HTML_Doctype_Info::__construct
Published: February 24, 2026
Last modified: August 20, 2026

---

# WP_HTML_Doctype_Info::__construct( string|null $name, string|null $public_identifier, string|null $system_identifier, bool $force_quirks_flag )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/__construct/?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.

Constructor.

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

This class should not be instantiated directly.
Use the static [WP_HTML_Doctype_Info::from_doctype_token](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/from_doctype_token/)
method instead.

The arguments to this constructor correspond to the “DOCTYPE token” as defined in
the HTML specification.

> DOCTYPE tokens have a name, a public identifier, a system identifier, and a force-
> quirks flag. When a DOCTYPE token is created, its name, public identifier, and
> system identifier must be marked as missing (which is a distinct state from the
> empty string), and the force-quirks flag must be set to off (its other state is
> on).

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

 * [https://html.spec.whatwg.org/multipage/parsing.html#tokenization](https://html.spec.whatwg.org/multipage/parsing.html#tokenization/)

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

 `$name`string|nullrequired

Name of the DOCTYPE.

`$public_identifier`string|nullrequired

Public identifier of the DOCTYPE.

`$system_identifier`string|nullrequired

System identifier of the DOCTYPE.

`$force_quirks_flag`boolrequired

Whether the force-quirks flag is set for the token.

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

    ```php
    private function __construct(
    	?string $name,
    	?string $public_identifier,
    	?string $system_identifier,
    	bool $force_quirks_flag
    ) {
    	$this->name              = $name;
    	$this->public_identifier = $public_identifier;
    	$this->system_identifier = $system_identifier;

    	/*
    	 * > If the DOCTYPE token matches one of the conditions in the following list,
    	 * > then set the Document to quirks mode:
    	 */

    	/*
    	 * > The force-quirks flag is set to on.
    	 */
    	if ( $force_quirks_flag ) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * Normative documents will contain the literal `<!DOCTYPE html>` with no
    	 * public or system identifiers; short-circuit to avoid extra parsing.
    	 */
    	if ( 'html' === $name && null === $public_identifier && null === $system_identifier ) {
    		$this->indicated_compatibility_mode = 'no-quirks';
    		return;
    	}

    	/*
    	 * > The name is not "html".
    	 *
    	 * The tokenizer must report the name in lower case even if provided in
    	 * the document in upper case; thus no conversion is required here.
    	 */
    	if ( 'html' !== $name ) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * Set up some variables to handle the rest of the conditions.
    	 *
    	 * > set...the public identifier...to...the empty string if the public identifier was missing.
    	 * > set...the system identifier...to...the empty string if the system identifier was missing.
    	 * >
    	 * > The system identifier and public identifier strings must be compared...
    	 * > in an ASCII case-insensitive manner.
    	 */
    	$public_identifier = null === $public_identifier ? '' : strtolower( $public_identifier );
    	$system_identifier = null === $system_identifier ? '' : strtolower( $system_identifier );

    	/*
    	 * > The public identifier is set to…
    	 */
    	if (
    		'-//w3o//dtd w3 html strict 3.0//en//' === $public_identifier ||
    		'-/w3c/dtd html 4.0 transitional/en' === $public_identifier ||
    		'html' === $public_identifier
    	) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * > The system identifier is set to…
    	 */
    	if ( 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd' === $system_identifier ) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * All of the following conditions depend on matching the public identifier.
    	 * If the public identifier is empty, none of the following conditions will match.
    	 */
    	if ( '' === $public_identifier ) {
    		$this->indicated_compatibility_mode = 'no-quirks';
    		return;
    	}

    	/*
    	 * > The public identifier starts with…
    	 *
    	 * @todo Optimize this matching. It shouldn't be a large overall performance issue,
    	 *       however, as only a single DOCTYPE declaration token should ever be parsed,
    	 *       and normative documents will have exited before reaching this condition.
    	 */
    	if (
    		str_starts_with( $public_identifier, '+//silmaril//dtd html pro v0r11 19970101//' ) ||
    		str_starts_with( $public_identifier, '-//as//dtd html 3.0 aswedit + extensions//' ) ||
    		str_starts_with( $public_identifier, '-//advasoft ltd//dtd html 3.0 aswedit + extensions//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0 level 1//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0 level 2//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0 strict level 1//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0 strict level 2//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0 strict//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.0//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 2.1e//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 3.0//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 3.2 final//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 3.2//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html 3//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html level 0//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html level 1//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html level 2//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html level 3//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html strict level 0//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html strict level 1//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html strict level 2//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html strict level 3//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html strict//' ) ||
    		str_starts_with( $public_identifier, '-//ietf//dtd html//' ) ||
    		str_starts_with( $public_identifier, '-//metrius//dtd metrius presentational//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 2.0 html strict//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 2.0 html//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 2.0 tables//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 3.0 html strict//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 3.0 html//' ) ||
    		str_starts_with( $public_identifier, '-//microsoft//dtd internet explorer 3.0 tables//' ) ||
    		str_starts_with( $public_identifier, '-//netscape comm. corp.//dtd html//' ) ||
    		str_starts_with( $public_identifier, '-//netscape comm. corp.//dtd strict html//' ) ||
    		str_starts_with( $public_identifier, "-//o'reilly and associates//dtd html 2.0//" ) ||
    		str_starts_with( $public_identifier, "-//o'reilly and associates//dtd html extended 1.0//" ) ||
    		str_starts_with( $public_identifier, "-//o'reilly and associates//dtd html extended relaxed 1.0//" ) ||
    		str_starts_with( $public_identifier, '-//sq//dtd html 2.0 hotmetal + extensions//' ) ||
    		str_starts_with( $public_identifier, '-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//' ) ||
    		str_starts_with( $public_identifier, '-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//' ) ||
    		str_starts_with( $public_identifier, '-//spyglass//dtd html 2.0 extended//' ) ||
    		str_starts_with( $public_identifier, '-//sun microsystems corp.//dtd hotjava html//' ) ||
    		str_starts_with( $public_identifier, '-//sun microsystems corp.//dtd hotjava strict html//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 3 1995-03-24//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 3.2 draft//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 3.2 final//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 3.2//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 3.2s draft//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 4.0 frameset//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html 4.0 transitional//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html experimental 19960712//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd html experimental 970421//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd w3 html//' ) ||
    		str_starts_with( $public_identifier, '-//w3o//dtd w3 html 3.0//' ) ||
    		str_starts_with( $public_identifier, '-//webtechs//dtd mozilla html 2.0//' ) ||
    		str_starts_with( $public_identifier, '-//webtechs//dtd mozilla html//' )
    	) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * > The system identifier is missing or the empty string, and the
    	 * > public identifier starts with…
    	 */
    	if (
    		'' === $system_identifier && (
    			str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) ||
    			str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' )
    		)
    	) {
    		$this->indicated_compatibility_mode = 'quirks';
    		return;
    	}

    	/*
    	 * > Otherwise, if the DOCTYPE token matches one of the conditions in
    	 * > the following list, then set the Document to limited-quirks mode.
    	 */

    	/*
    	 * > The public identifier starts with…
    	 */
    	if (
    		str_starts_with( $public_identifier, '-//w3c//dtd xhtml 1.0 frameset//' ) ||
    		str_starts_with( $public_identifier, '-//w3c//dtd xhtml 1.0 transitional//' )
    	) {
    		$this->indicated_compatibility_mode = 'limited-quirks';
    		return;
    	}

    	/*
    	 * > The system identifier is neither missing nor the empty string, and the
    	 * > public identifier starts with…
    	 */
    	if (
    		'' !== $system_identifier && (
    			str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) ||
    			str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' )
    		)
    	) {
    		$this->indicated_compatibility_mode = 'limited-quirks';
    		return;
    	}

    	$this->indicated_compatibility_mode = 'no-quirks';
    }
    ```

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

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

| Used by | Description | 
| [WP_HTML_Doctype_Info::from_doctype_token()](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/from_doctype_token/)`wp-includes/html-api/class-wp-html-doctype-info.php` |

Creates a [WP_HTML_Doctype_Info](https://developer.wordpress.org/reference/classes/wp_html_doctype_info/) instance by parsing a raw DOCTYPE declaration token.

  |

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