WP_HTML_Processor::is_void()public staticWP 6.4.0

Returns whether a given element is an HTML Void Element

area, base, br, col, embed, hr, img, input, link, meta, source, track, wbr

Method of the class: WP_HTML_Processor{}

No Hooks.

Return

true|false. Whether the given tag is an HTML Void Element.

Usage

$result = WP_HTML_Processor::is_void( $tag_name );
$tag_name(string) (required)
Name of HTML tag to check.

Notes

Changelog

Since 6.4.0 Introduced.

WP_HTML_Processor::is_void() code WP 6.6.2

public static function is_void( $tag_name ) {
	$tag_name = strtoupper( $tag_name );

	return (
		'AREA' === $tag_name ||
		'BASE' === $tag_name ||
		'BASEFONT' === $tag_name || // Obsolete but still treated as void.
		'BGSOUND' === $tag_name || // Obsolete but still treated as void.
		'BR' === $tag_name ||
		'COL' === $tag_name ||
		'EMBED' === $tag_name ||
		'FRAME' === $tag_name ||
		'HR' === $tag_name ||
		'IMG' === $tag_name ||
		'INPUT' === $tag_name ||
		'KEYGEN' === $tag_name || // Obsolete but still treated as void.
		'LINK' === $tag_name ||
		'META' === $tag_name ||
		'PARAM' === $tag_name || // Obsolete but still treated as void.
		'SOURCE' === $tag_name ||
		'TRACK' === $tag_name ||
		'WBR' === $tag_name
	);
}