Opened 2 years ago
Closed 8 months ago
#16538 closed enhancement (maybelater)
Add placeholder attribute to search field
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | info@…, chip@… |
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)
Change History (11)
comment:2
in reply to:
↑ 1
solarissmoke
— 2 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.
solarissmoke
— 2 years ago
comment:3
solarissmoke
— 2 years ago
- Keywords has-patch added
comment:4
follow-up:
↓ 5
ocean90
— 2 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:
↓ 6
cyberskull
— 2 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:
↓ 8
nacin
— 2 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
toscho
— 2 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
cyberskull
— 2 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:10
helenyhou
— 8 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.
I don't think we are type=search in core. We should, though.
Placeholders don't degrade gracefully in browsers, do they?