content icon indicating copy to clipboard operation
content copied to clipboard

Mobile and desktop parity for the select element

Open josepharhar opened this issue 8 months ago • 11 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/select

What specific section or headline is this issue about?

multiple and size attributes

What information was incorrect, unhelpful, or incomplete?

The HTML spec is changing and chrome has already shipped what I called "mobile desktop parity" for the select element, meaning that the select element will now render as a drop-down box or a listbox consistently across mobile and desktop platforms given the same combination of multiple and size attributes. Prior to this change, desktop showed either a listbox or a drop-down box but didn't support a drop-down box for <select multiple>, and mobile didn't support a listbox in any configuration.

Here is a table which explains the new behavior:

HTML rendering mode
<select> drop-down box
<select size=4> (any size > 1) listbox
<select multiple> listbox
<select muiltiple size=1> drop-down box

The spec was written such that <select multiple size=1> might still be a listbox on certain platforms because macos appkit doesn't have a native picker for this, so it is likely that safari will still make this a listbox on macos. Chrome makes this a drop-down box on all platforms.

What did you expect to see?

Documentation about <select multiple size=1> at least, which is sort of a new thing we created. I think the table about rendering modes would also be helpful to show to authors.

Do you have any supporting links, references, or citations?

  • https://github.com/whatwg/html/pull/11460
  • https://chromestatus.com/feature/5412736871825408

Do you have anything more you want to share?

@chrisdavidmills

josepharhar avatar Mar 10 '26 23:03 josepharhar

HTML rendering mode
<select> drop-down box
<select size=4> (any size > 1) listbox
<select multiple> listbox
<select muiltiple size=1> drop-down box

Hi! I'd like to help update this documentation.

Would it make sense to add a small subsection under the size attribute (in the Attributes section) describing the rendering behavior when multiple and size are combined, including the <select multiple size="1"> case?

I was thinking of adding a short table explaining the typical rendering (drop-down vs listbox). If that sounds good, I'd be happy to open a PR for it.

Let me know if this approach works or if you'd prefer it documented somewhere else.

mohammed-ali-osman avatar Mar 11 '26 08:03 mohammed-ali-osman

Thanks for filing, @josepharhar. Some questions for clarification:

  • When you say "but didn't support a drop-down box for <select multiple>", are you specifically talking about when using <select multiple size=1> to create a drop-down? <select multiple> would create a listbox.
  • This work is separate from customizable selects, right? I've just read the ChromeStatus entry, and it looks like it is saying this is a precursor to get the default story consistent before you start implementing customizable <select multiple size=1>? I just thought I'd check.
  • What is the cross-browser story like for this change? We need to be careful to represent the whole story, not just the chrome story. I'd suggest adding a BCD entry for this change, and having some kind of separate section on the <select> page to discuss the full story of the rendering of dropdowns versus listboxes, which the size and multiple attribute definitions can link to. There are a few details on the page already, but they are fragmented.
  • Is it fair to say that, really, this change is mostly about getting <select multiple size=1> to render a dropdown consistently across browsers? This will affect the BCD and the tone of the new section.

Thanks for showing an interest in helping with this issue, @mohammed-ali-osman. This could be a bit trickier than you might first think, hence my gathering some more details with my questions above. Let's see what @josepharhar says.

chrisdavidmills avatar Mar 11 '26 11:03 chrisdavidmills

Thanks! Happy to help — I’ll follow along and provide input where I can. Looking forward to hearing what @josepharhar says.

mohammed-ali-osman avatar Mar 11 '26 12:03 mohammed-ali-osman

When you say "but didn't support a drop-down box for <select multiple>", are you specifically talking about when using <select multiple size=1> to create a drop-down? <select multiple> would create a listbox.

Yes, I am specifically talking about <select multiple size=1>, I should have been more specific.

This work is separate from customizable selects, right? I've just read the ChromeStatus entry, and it looks like it is saying this is a precursor to get the default story consistent before you start implementing customizable <select multiple size=1>? I just thought I'd check.

<select multiple size=1> was part of it, but the main motivation for me was for launching customizable select listboxes on mobile, since before this it wasn't possible to get a listbox on mobile.

What is the cross-browser story like for this change? We need to be careful to represent the whole story, not just the chrome story. I'd suggest adding a BCD entry for this change, and having some kind of separate section on the <select> page to discuss the full story of the rendering of dropdowns versus listboxes, which the size and multiple attribute definitions can link to. There are a few details on the page already, but they are fragmented.

The other browsers haven't implemented this yet, at least I don't think they have. How do I add a BCD entry?

This also makes me realize that I should add the nuance about the macos safari thing to the table based on what we have agreed and discussed so far. Here is a better one:

HTML appearance rendering mode
<select> auto or base drop-down box
<select size=4> auto or base listbox
<select multiple> auto or base listbox
<select multiple size=1> base drop-down box
<select multiple size=1> auto listbox on MacOS safari, drop-down box on other platforms and browsers

Is it fair to say that, really, this change is mostly about getting <select multiple size=1> to render a dropdown consistently across browsers? This will affect the BCD and the tone of the new section.

<select multiple size=1> will consistently be a dropdown across browsers if appearance:base-select is used, but not if appearance:auto is used due to the MacOS safari issue.

To me, it is mostly about getting listboxes on mobile.

josepharhar avatar Mar 18 '26 20:03 josepharhar

I have now mentioned this, under size:

This attribute represents the number of options to show at once, and must be a positive integer. If the value is 1, browsers will render a drop-down list. If the value is greater than 1, browsers will render a scrolling list box that has the specified number of rows visible.

multiple no longer mentions how it's rendered, only the UX that you can select zero or more options.

I'm not sure if any BCD is necessary since browsers are always free to pick their presentation.

Josh-Cena avatar Aug 12 '26 21:08 Josh-Cena

Thanks! Yeah I think that the BCD here covers what should be covered: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select#browser_compatibility

I do wonder if we should link to that in more pages though, like this one, or the main select element page: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select_listboxes

josepharhar avatar Aug 14 '26 15:08 josepharhar

Hi! I’d like to help with the remaining work on this issue.

From the recent discussion, it looks like the size behavior has already been clarified. Would a useful next step be to add a link from the main <select> element page to the customizable select/listbox documentation mentioned above?

I’m happy to keep the change small and focused if that is still wanted. Please let me know if there is another remaining part of this issue that would be more useful to address.

surajchi avatar Aug 20 '26 07:08 surajchi

@josepharhar AFAIS, this issue is only about the default browser rendering of the select element and not its customization capability? Shouldn't linking to "Customizable select" be more relevant for https://github.com/mdn/content/issues/42358?

Josh-Cena avatar Aug 21 '26 18:08 Josh-Cena

Yes, https://github.com/mdn/content/issues/42358 would be more relevant to discuss that

josepharhar avatar Aug 21 '26 20:08 josepharhar

Hi! I came here from #43403 after the discussion about linking the main <select> documentation to the customizable select resources.

I’d be interested in helping with a small, focused documentation update here if that work is still needed. I can review the current <select> pages and add the most relevant link(s) to the customizable select documentation without expanding the scope beyond this issue.

Please let me know if this would be useful before I open a PR.

surajchi avatar Aug 22 '26 07:08 surajchi

FYI I found some text saying that size=1 is bad, I opened another issue about that here: https://github.com/mdn/content/issues/45988

josepharhar avatar Oct 05 '26 23:10 josepharhar