Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering option with empty label attribute or whitespace #10955

Open
josepharhar opened this issue Jan 27, 2025 · 4 comments
Open

Rendering option with empty label attribute or whitespace #10955

josepharhar opened this issue Jan 27, 2025 · 4 comments
Labels
interop Implementations are not interoperable with each other topic: select The <select> element

Comments

@josepharhar
Copy link
Contributor

What is the issue with the HTML Standard?

The following HTML has different rendering in chrome, firefox, and safari:

<select multiple>
  <option label="">empty label attribute</option>
  <option label="  ">whitespace label attribute</option>
</select>
<br>
<select>
  <option label="">empty label attribute</option>
  <option label="  ">whitespace label attribute</option>
</select>

Chrome: empty and whitespace label attributes are not used

Image

Firefox: empty label attribute is not used, whitespace label attribute is used

Image

WebKit: empty and whitespace label attributes are used

Image

The spec says this:

An option element is expected to be rendered by displaying the element's label, indented under its optgroup element if it has one.

The label of an option element is the value of the label content attribute, if there is one and its value is not the empty string, or, otherwise, the value of the element's text IDL attribute.

Just based on reading the spec, I think that firefox is the compliant one. But what do yall think the best behavior is?

@josepharhar josepharhar added the topic: select The <select> element label Jan 27, 2025
@domenic domenic added the interop Implementations are not interoperable with each other label Jan 28, 2025
@annevk
Copy link
Member

annevk commented Jan 28, 2025

Not sure, if you really wanted a label to appear empty it's possible in all engines I suspect, it just depends on how persistent you are. (I would imagine whitespace of the non-ASCII variety to work in Chromium, for instance.)

There's probably not a good use case for that though.

So since all engines are different and it doesn't really matter, I guess I would opt for not changing the specification.

@josepharhar
Copy link
Contributor Author

Thanks! I'll implement the firefox behavior in chromium with no spec changes, since I believe that firefox does what the spec says.

@josepharhar
Copy link
Contributor Author

I found a chrome internal test which claims that the whitespace behavior is to match IE, so I'll change the behavior in chromium behind a flag and report back if any issues come up.

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/fast/forms/select/HTMLOptionElement_label03.html;l=3;drc=77578ccb4082ae20a9326d9e673225f1189ebb63

@annevk
Copy link
Member

annevk commented Jan 30, 2025

Are there web-platform-tests? Typically we leave issues open until at least the standard and tests are in alignment.

@annevk annevk reopened this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: select The <select> element
Development

No branches or pull requests

3 participants