esc_html__()WP 2.8.0

Translates specified string and escapes it for safe use in HTML output.

If there is no translation, or the text domain isn't loaded, the original text is escaped and returned.

No Hooks.


String. Translated and escaped string for output in HTML.


esc_html__( $text, $domain );
$text(string) (required)
Text to translate.
Text domain. Unique identifier for retrieving translated strings.
Default: 'default'



#1 Output in the tag

If the translation has HTML tags or characters that need to be shown as it is, for example in <textarea> tag, then it is smart to translate it with this function:

	<?php echo esc_html__('Any text with <span>HTML.</span>', 'textdomain'); ?>

#2 Same as in the first example but in a different way

<?php echo esc_html( __('Any text with <span>HTML.</span>', 'textdomain') );


Since 2.8.0 Introduced.

esc_html__() code WP 6.4.3

function esc_html__( $text, $domain = 'default' ) {
	return esc_html( translate( $text, $domain ) );