Render an option's label attribute when not using base appearance - #12936
Merged
Merged
Conversation
Defining customizable `<select>` in 172cccf replaced "displaying the element's label" with "displaying the result of collect option text given the option and true", which never consults the label content attribute and strips and collapses whitespace. As written, `<option label="foo">bar</option>` displays "bar", and an option whose label attribute is a single space displays nothing. Blink, Gecko, and WebKit instead display the label attribute's value as-is when it is not the empty string, and the option's text otherwise. That is what option-label-whitespace.html and option-label-whitespace-2.html in html/rendering/replaced-elements/the-option-element/ test. The rendering section could not simply reference the option's label because it needs img alt text included. So the label is now an algorithm that takes the same includeAltText boolean as collect option text, mirroring "get an optgroup element's label": the label IDL attribute getter passes false and rendering passes true. Base appearance is unaffected; the option contents slot and option label element already work this way. While there, add a missing "the" to the sentences introducing the label and value attributes. Fixes #10955.
annevk
force-pushed
the
option-label-rendering
branch
from
September 14, 2026 09:48
4c469ee to
8db1b4a
Compare
zcorpan
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Render an option's label attribute when not using base appearance
Defining customizable
<select>in 172cccf replaced "displaying theelement's label" with "displaying the result of collect option text
given the option and true", which never consults the label content
attribute and strips and collapses whitespace. As written,
<option label="foo">bar</option>displays "bar", and an option whoselabel attribute is a single space displays nothing.
Blink, Gecko, and WebKit instead display the label attribute's value
as-is when it is not the empty string, and the option's text otherwise.
That is what option-label-whitespace.html and
option-label-whitespace-2.html in
html/rendering/replaced-elements/the-option-element/ test.
The rendering section could not simply reference the option's label
because it needs img alt text included. So the label is now an algorithm
that takes the same includeAltText boolean as collect option text,
mirroring "get an optgroup element's label": the label IDL attribute
getter passes false and rendering passes true.
Base appearance is unaffected; the option contents slot and option label
element already work this way.
While there, add a missing "the" to the sentences introducing the label
and value attributes.
Fixes #10955.
The prose this restores was lost in #10548 and stayed lost through #12201; base appearance, defined by those same PRs, already gets it right.
<select>#10548 text)(See WHATWG Working Mode: Changes for more details.)
/form-elements.html ( diff )
/rendering.html ( diff )