Title: esc_attr_e
Published: April 25, 2014
Last modified: August 20, 2026

---

# esc_attr_e( string $text, string $domain = 'default' )

## In this article

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

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

Displays translated text that has been escaped for safe use in an attribute.

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

Encodes `< > & " '` (less than, greater than, ampersand, double quote, single quote).

Will never double encode entities.

If you need the value for use in PHP, use [esc_attr__()](https://developer.wordpress.org/reference/functions/esc_attr__/).

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

 `$text`stringrequired

Text to translate.

`$domain`stringoptional

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

Default:`'default'`

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

    ```php
    function esc_attr_e( $text, $domain = 'default' ) {
    	echo esc_attr( 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/7.1/src/wp-includes/l10n.php#L370)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/l10n.php#L370-L372)

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

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

Retrieves the translation of $text.

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

Escaping for HTML attributes.

  |

| Used by | Description | 
| [WP_Customize_Themes_Panel::render_template()](https://developer.wordpress.org/reference/classes/wp_customize_themes_panel/render_template/)`wp-includes/customize/class-wp-customize-themes-panel.php` |

An Underscore (JS) template for rendering this panel’s container.

  | 
| [WP_Customize_Themes_Section::render_template()](https://developer.wordpress.org/reference/classes/wp_customize_themes_section/render_template/)`wp-includes/customize/class-wp-customize-themes-section.php` |

Renders a themes section as a JS template.

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

Prints the markup for the Community Events section of the Events and News Dashboard widget.

  | 
| [WP_Customize_Nav_Menus::print_custom_links_available_menu_item()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus/print_custom_links_available_menu_item/)`wp-includes/class-wp-customize-nav-menus.php` |

Prints the markup for available menu item custom links.

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

Prints the necessary markup for the embed sharing button.

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

Prints the necessary markup for the embed sharing dialog.

  | 
| [WP_Customize_Nav_Menu_Location_Control::render_content()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menu_location_control/render_content/)`wp-includes/customize/class-wp-customize-nav-menu-location-control.php` |

Render content just like a normal select control.

  | 
| [WP_Customize_Nav_Menu_Control::content_template()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menu_control/content_template/)`wp-includes/customize/class-wp-customize-nav-menu-control.php` |

JS/Underscore template for the control UI.

  | 
| [WP_Customize_Manager::render_control_templates()](https://developer.wordpress.org/reference/classes/wp_customize_manager/render_control_templates/)`wp-includes/class-wp-customize-manager.php` |

Renders JS templates for all registered control types.

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

Print JavaScript templates required for the revisions experience.

  | 
| [WP_Media_List_Table::views()](https://developer.wordpress.org/reference/classes/wp_media_list_table/views/)`wp-admin/includes/class-wp-media-list-table.php` |

Overrides parent views to use the filter bar display.

  | 
| [login_footer()](https://developer.wordpress.org/reference/functions/login_footer/)`wp-login.php` |

Outputs the footer for the login page.

  | 
| [signup_another_blog()](https://developer.wordpress.org/reference/functions/signup_another_blog/)`wp-signup.php` |

Shows a form for returning users to sign up for another site.

  | 
| [signup_user()](https://developer.wordpress.org/reference/functions/signup_user/)`wp-signup.php` |

Shows a form for a visitor to sign up for a new user account.

  | 
| [signup_blog()](https://developer.wordpress.org/reference/functions/signup_blog/)`wp-signup.php` |

Shows a form for a user or visitor to sign up for a new site.

  | 
| [display_setup_form()](https://developer.wordpress.org/reference/functions/display_setup_form/)`wp-admin/install.php` |

Displays installer setup form.

  | 
| [WP_Screen::render_screen_meta()](https://developer.wordpress.org/reference/classes/wp_screen/render_screen_meta/)`wp-admin/includes/class-wp-screen.php` |

Renders the screen’s help section.

  | 
| [wp_image_editor()](https://developer.wordpress.org/reference/functions/wp_image_editor/)`wp-admin/includes/image-edit.php` |

Loads the WP image-editing interface.

  | 
| [WP_Theme_Install_List_Table::theme_installer()](https://developer.wordpress.org/reference/classes/wp_theme_install_list_table/theme_installer/)`wp-admin/includes/class-wp-theme-install-list-table.php` |

Prints the wrapper for the theme installer.

  | 
| [install_plugins_favorites_form()](https://developer.wordpress.org/reference/functions/install_plugins_favorites_form/)`wp-admin/includes/plugin-install.php` |

Shows a username form for the favorites page.

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

Displays the Quick Draft widget.

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

Outputs the modal window used for attaching media to posts or pages in the media-listing screen.

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

Adds gallery form to upload iframe.

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

Outputs the legacy media upload form.

  | 
| [link_submit_meta_box()](https://developer.wordpress.org/reference/functions/link_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays link create form fields.

  | 
| [link_categories_meta_box()](https://developer.wordpress.org/reference/functions/link_categories_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays link categories form fields.

  | 
| [post_submit_meta_box()](https://developer.wordpress.org/reference/functions/post_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays post submit form fields.

  | 
| [attachment_submit_meta_box()](https://developer.wordpress.org/reference/functions/attachment_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays attachment submit form fields.

  | 
| [post_tags_meta_box()](https://developer.wordpress.org/reference/functions/post_tags_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays post tags form fields.

  | 
| [wp_nav_menu_item_link_meta_box()](https://developer.wordpress.org/reference/functions/wp_nav_menu_item_link_meta_box/)`wp-admin/includes/nav-menu.php` |

Displays a meta box for the custom links menu item.

  | 
| [wp_nav_menu_item_post_type_meta_box()](https://developer.wordpress.org/reference/functions/wp_nav_menu_item_post_type_meta_box/)`wp-admin/includes/nav-menu.php` |

Displays a meta box for a post type menu item.

  | 
| [wp_nav_menu_item_taxonomy_meta_box()](https://developer.wordpress.org/reference/functions/wp_nav_menu_item_taxonomy_meta_box/)`wp-admin/includes/nav-menu.php` |

Displays a meta box for a taxonomy menu item.

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

Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.

  | 
| [Custom_Image_Header::step_1()](https://developer.wordpress.org/reference/classes/custom_image_header/step_1/)`wp-admin/includes/class-custom-image-header.php` |

Displays first step of custom header image page.

  | 
| [list_plugin_updates()](https://developer.wordpress.org/reference/functions/list_plugin_updates/)`wp-admin/update-core.php` |

Display the upgrade plugins form.

  | 
| [list_theme_updates()](https://developer.wordpress.org/reference/functions/list_theme_updates/)`wp-admin/update-core.php` |

Display the upgrade themes form.

  | 
| [list_translation_updates()](https://developer.wordpress.org/reference/functions/list_translation_updates/)`wp-admin/update-core.php` |

Display the update translations form.

  | 
| [Custom_Background::admin_page()](https://developer.wordpress.org/reference/classes/custom_background/admin_page/)`wp-admin/includes/class-custom-background.php` |

Displays the custom background page.

  | 
| [WP_Admin_Bar::_render()](https://developer.wordpress.org/reference/classes/wp_admin_bar/_render/)`wp-includes/class-wp-admin-bar.php` |  | 
| [WP_Customize_Header_Image_Control::render_content()](https://developer.wordpress.org/reference/classes/wp_customize_header_image_control/render_content/)`wp-includes/customize/class-wp-customize-header-image-control.php` |

Renders the control’s content.

  | 
| [WP_Widget_Area_Customize_Control::render_content()](https://developer.wordpress.org/reference/classes/wp_widget_area_customize_control/render_content/)`wp-includes/customize/class-wp-widget-area-customize-control.php` |

Renders the control’s content.

  | 
| [_WP_Editors::wp_link_dialog()](https://developer.wordpress.org/reference/classes/_wp_editors/wp_link_dialog/)`wp-includes/class-wp-editor.php` |

Dialog for internal linking.

  | 
| [wp_print_media_templates()](https://developer.wordpress.org/reference/functions/wp_print_media_templates/)`wp-includes/media-template.php` |

Prints the templates used in the media manager.

  |

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

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/esc_attr_e/?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_attr_e/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/esc_attr_e/?output_format=md#comment-content-3122)
 2.   [Marcio Zebedeu](https://profiles.wordpress.org/marcio-zebedeu/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/esc_attr_e/#comment-3122)
 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_attr_e%2F%23comment-3122)
    Vote results for this note: 2[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_attr_e%2F%23comment-3122)
 4. the esc_attr_e function it echoing the value for example:
 5.     ```php
        <input title="<?php esc_attr_e( 'Read More', 'your_text_domain' ) ?>" type="submit" value="submit" />
        // Returns <input title="Read More" type="submit" value="submit" />
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_attr_e%2F%3Freplytocom%3D3122%23feedback-editor-3122)

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