Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#16538 closed enhancement (maybelater)

Add placeholder attribute to search field

Reported by: cyberskull's profile 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 14 years ago.

Download all attachments as: .zip

Change History (11)

#1 follow-up: @nacin
14 years ago

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

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

#2 in reply to: ↑ 1 @solarissmoke
14 years ago

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

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

Last edited 14 years ago by solarissmoke (previous) (diff)

@solarissmoke
14 years ago

#3 @solarissmoke
14 years ago

  • Keywords has-patch added

#4 follow-up: @ocean90
14 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.

#5 in reply to: ↑ 4 ; follow-up: @cyberskull
14 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.

#6 in reply to: ↑ 5 ; follow-up: @nacin
14 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.

#7 @toscho
14 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.

#8 in reply to: ↑ 6 @cyberskull
14 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.

#9 @chipbennett
13 years ago

  • Cc chip@… added

Related: #19579

#10 @helenyhou
13 years 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.