i was going through a search and found this button in search form.

<button type="submit" class="search-submit">
        <span class="genericon-search"></span>
        <span class="screen-reader-text"><?php echo esc_html_x( 'Search', 'submit button', ); ?></span>

I want to know what’s the use of the <span class="screen-reader-text"><?php echo esc_html_x( 'Search', 'submit button', ); ?> in this search form, its also working when i remove this line.

1 Answer
1

This class is used to visually hide elements from sighted users but still allows assistive technologies like screen readers to still present those elements to users who are visually impaired.

For example you may have an icon with Facebook’s logo as a link to your page/profile. A sighted user will know that’s Facebook but a blind user won’t so you would still want “My Facebook Profile” or some other descriptive text to let visually impaired people know more about the link.

Leave a Reply

Your email address will not be published. Required fields are marked *