WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 18 months ago

#16538 closed enhancement (maybelater)

Add placeholder attribute to search field

Reported by: cyberskull Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Template Keywords: has-patch
Focuses: Cc:

Description

By default the search widget is just a blank field. This is really unfortunate. However, HTML5 has a solution! Since the search field is already {{type="search"}}, we only need to add the attribute placeholder="Search" to the element.

<hmtl>
…
<form action="http://example.com/" method="get" id="searchform-1">
<input type="search" name="s" id="s-1" placeholder="search" />
</form>
…
</html>

Attachments (1)

16538.diff (2.2 KB) - added by solarissmoke 3 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 follow-up: nacin3 years ago

I don't think we are type=search in core. We should, though.

Placeholders don't degrade gracefully in browsers, do they?

comment:2 in reply to: ↑ 1 solarissmoke3 years ago

Placeholders don't degrade gracefully in browsers, do they?

There is nothing to degrade? Browsers that don't support it (eg IE<8, FF<4) just ignore it.

Version 0, edited 3 years ago by solarissmoke (next)

solarissmoke3 years ago

comment:3 solarissmoke3 years ago

  • Keywords has-patch added

comment:4 follow-up: ocean903 years ago

You can change the form with the get_search_form filter. So if you have a theme with HTML5 doctype you can add the new attribute.

In my opinion it's too soon to add HTML5 attributes into the core.

comment:5 in reply to: ↑ 4 ; follow-up: cyberskull3 years ago

Replying to ocean90:

You can change the form with the get_search_form filter. So if you have a theme with HTML5 doctype you can add the new attribute.

In my opinion it's too soon to add HTML5 attributes into the core.

The attribute type="search" is an HTML5 attribute and is already in core.

comment:6 in reply to: ↑ 5 ; follow-up: nacin3 years ago

Replying to cyberskull:

The attribute type="search" is an HTML5 attribute and is already in core.

No, it's not. Your theme probably has a custom searchform.php.

comment:7 toscho3 years ago

  • Cc info@… added

By default the search widget is just a blank field.

That depends on the theme. By default the search field has a label.

If we add a placeholder users with a screenreader and a modern browser have to listen to the label and the placeholder. As long as there is not better text for the placeholder than an illegal label replacement/duplicate no one benefits from the attribute.

comment:8 in reply to: ↑ 6 cyberskull3 years ago

Replying to nacin:

Replying to cyberskull:

The attribute type="search" is an HTML5 attribute and is already in core.

No, it's not. Your theme probably has a custom searchform.php.

My mistake then.

comment:9 chipbennett2 years ago

  • Cc chip@… added

Related: #19579

comment:10 helenyhou18 months ago

  • Component changed from UI to Template
  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Let's leave it to themes for now.

Note: See TracTickets for help on using tickets.