esc_html_e()WP 2.8.0

Translates specified string and escape/clears it for showing on screen - replaces special characters in it with HTML entities.

Displays text that can be used in HTML as HTML code.

use esc_html__() for get the same sting without printing it.

No Hooks.


null. Nothing (null).


esc_html_e( $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 such a string with this function:

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

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

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

// Or so
echo esc_html__( 'Any text with <div>HTML.</div>', 'kama' );


Since 2.8.0 Introduced.

esc_html_e() code WP 6.4.3

function esc_html_e( $text, $domain = 'default' ) {
	echo esc_html( translate( $text, $domain ) );