Title: esc_html__
Published: April 25, 2014
Last modified: February 24, 2026

---

# esc_html__( string $text, string $domain ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#wp--skip-link--target)

Retrieves the translation of $text and escapes it for safe use in HTML output.

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

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

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

 `$text`stringrequired

Text to translate.

`$domain`stringoptional

Text domain. Unique identifier for retrieving translated strings.
 Default `'default'`.

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

 string Translated text.

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

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/l10n.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/l10n.php#L339)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/l10n.php#L339-L341)

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

| Uses | Description | 
| [translate()](https://developer.wordpress.org/reference/functions/translate/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  |

| Used by | Description | 
| [WP_Script_Modules::print_a11y_script_module_html()](https://developer.wordpress.org/reference/classes/wp_script_modules/print_a11y_script_module_html/)`wp-includes/class-wp-script-modules.php` |  | 
| [get_the_block_template_html()](https://developer.wordpress.org/reference/functions/get_the_block_template_html/)`wp-includes/block-template.php` |

Returns the markup for the current template.

  | 
| [WP_Application_Passwords_List_Table::print_js_template_row()](https://developer.wordpress.org/reference/classes/wp_application_passwords_list_table/print_js_template_row/)`wp-admin/includes/class-wp-application-passwords-list-table.php` |

Prints the JavaScript template for the new row item.

  | 
| [Plugin_Installer_Skin::do_overwrite()](https://developer.wordpress.org/reference/classes/plugin_installer_skin/do_overwrite/)`wp-admin/includes/class-plugin-installer-skin.php` |

Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload.

  | 
| [Theme_Installer_Skin::do_overwrite()](https://developer.wordpress.org/reference/classes/theme_installer_skin/do_overwrite/)`wp-admin/includes/class-theme-installer-skin.php` |

Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload.

  | 
| [WP_Privacy_Data_Removal_Requests_List_Table::column_next_steps()](https://developer.wordpress.org/reference/classes/wp_privacy_data_removal_requests_list_table/column_next_steps/)`wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php` |

Outputs the Next steps column.

  | 
| [WP_Privacy_Data_Export_Requests_List_Table::column_next_steps()](https://developer.wordpress.org/reference/classes/wp_privacy_data_export_requests_list_table/column_next_steps/)`wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php` |

Displays the next steps column.

  | 
| [wp_privacy_generate_personal_data_export_group_html()](https://developer.wordpress.org/reference/functions/wp_privacy_generate_personal_data_export_group_html/)`wp-admin/includes/privacy-tools.php` |

Generate a single group for the personal data export report.

  | 
| [wp_privacy_generate_personal_data_export_file()](https://developer.wordpress.org/reference/functions/wp_privacy_generate_personal_data_export_file/)`wp-admin/includes/privacy-tools.php` |

Generate the personal data export file.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#comment-content-1668)
 2.    [izem](https://profiles.wordpress.org/izem/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/esc_html__/#comment-1668)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-1668)
     Vote results for this note: 5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-1668)
 4.  Use to embed translations inside HTML. This way you ensure that third party translation
     are sanitized and will not break the code (proper security to keep the users safe).
 5.      ```php
         <h1><?php echo esc_html__( 'Title', 'text-domain' ) ?></h3>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%3Freplytocom%3D1668%23feedback-editor-1668)
 7.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#comment-content-2667)
 8.    [danieltj](https://profiles.wordpress.org/danieltj/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/esc_html__/#comment-2667)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-2667)
     Vote results for this note: 5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-2667)
 10. When using `esc_html__`, remember that it’s also possible to echo the string value
     out by using the related `esc_html_e` which does the same thing but echoes the
     string too.
 11. An example:
 12.     ```php
         <p><?php esc_html_e( 'Hello World!', 'text-domain' ); ?></p>
         ```
     
 13. You can also read more about [`esc_html_e`](https://developer.wordpress.org/reference/functions/esc_html_e/)
     too.
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%3Freplytocom%3D2667%23feedback-editor-2667)
 15.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/esc_html__/?output_format=md#comment-content-7287)
 16.   [Mehraz Morshed](https://profiles.wordpress.org/mehrazmorshed/)  [  1 year ago  ](https://developer.wordpress.org/reference/functions/esc_html__/#comment-7287)
 17. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-7287)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%23comment-7287)
 18. **[esc_html()](https://developer.wordpress.org/reference/functions/esc_html/) **
     is for escaping.
      **[esc_html__()](https://developer.wordpress.org/reference/functions/esc_html__/)**
     is for translating and escaping. **[esc_html_e()](https://developer.wordpress.org/reference/functions/esc_html_e/)**
     is for translating, escaping and directly echoing.
 19.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F%3Freplytocom%3D7287%23feedback-editor-7287)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_html__%2F)
before being able to contribute a note or feedback.