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

the default option of a select #36658

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

the default option of a select #36658

wants to merge 2 commits into from

Conversation

jolka-ef
Copy link
Contributor

@jolka-ef jolka-ef commented Nov 5, 2024

Update information about the selected option.

Fixes #36573

@jolka-ef jolka-ef requested a review from a team as a code owner November 5, 2024 11:43
@jolka-ef jolka-ef requested review from chrisdavidmills and removed request for a team November 5, 2024 11:43
@github-actions github-actions bot added the Content:HTML Hypertext Markup Language docs label Nov 5, 2024
@github-actions github-actions bot added the size/xs [PR only] 0-5 LoC changed label Nov 5, 2024
Copy link
Contributor

github-actions bot commented Nov 5, 2024

Preview URLs

Copy link
Contributor

github-actions bot commented Nov 5, 2024

Preview URLs

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @jolka-ef , and thank you for your contribution to MDN! What you added was fine, but I've offered a suggestion that I feel makes it a little clearer, plus I've also suggested an extra sentence that provides another bit of information that was missing. Let me know what you think!

@@ -13,7 +13,7 @@ The **`<select>`** [HTML](/en-US/docs/Web/HTML) element represents a control tha

The above example shows typical `<select>` usage. It is given an `id` attribute to enable it to be associated with a {{htmlelement("label")}} for accessibility purposes, as well as a `name` attribute to represent the name of the associated data point submitted to the server. Each menu option is defined by an {{htmlelement("option")}} element nested inside the `<select>`.

Each `<option>` element should have a [`value`](/en-US/docs/Web/HTML/Element/option#value) attribute containing the data value to submit to the server when that option is selected. If no `value` attribute is included, the value defaults to the text contained inside the element. You can include a [`selected`](/en-US/docs/Web/HTML/Element/option#selected) attribute on an `<option>` element to make it selected by default when the page first loads.
Each `<option>` element should have a [`value`](/en-US/docs/Web/HTML/Element/option#value) attribute containing the data value to submit to the server when that option is selected. If no `value` attribute is included, the value defaults to the text contained inside the element. You can include a [`selected`](/en-US/docs/Web/HTML/Element/option#selected) attribute on an `<option>` element to make it selected by default when the page first loads. The first element will be selected as the default if none is specified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Each `<option>` element should have a [`value`](/en-US/docs/Web/HTML/Element/option#value) attribute containing the data value to submit to the server when that option is selected. If no `value` attribute is included, the value defaults to the text contained inside the element. You can include a [`selected`](/en-US/docs/Web/HTML/Element/option#selected) attribute on an `<option>` element to make it selected by default when the page first loads. The first element will be selected as the default if none is specified.
Each `<option>` element should have a [`value`](/en-US/docs/Web/HTML/Element/option#value) attribute containing the data value to submit to the server when that option is selected. If no `value` attribute is included, the value defaults to the text contained inside the element. You can include a [`selected`](/en-US/docs/Web/HTML/Element/option#selected) attribute on an `<option>` element to make it selected by default when the page first loads. If no `selected` attribute is specified, the first `<option>` element will be selected by default. If multiple `<option>` elements have `selected` attributes specified, the last one in the source order will be selected by default.

@jolka-ef
Copy link
Contributor Author

jolka-ef commented Nov 5, 2024

@chrisdavidmills Before I begin my actual comment, I would like to apologize in advance for my inadequate level of English proficiency.
I am not a native speaker :)
I think the text is now much better and clearer, although I have some doubts about this part

If multiple <option> elements have selected attributes specified, the last one in the source order will be selected by default.

because if I understand the specification correctly, that's not usage they encourage.
Specs states

A select element whose multiple attribute is not specified must not have more than one descendant option element with its selected attribute set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTML Hypertext Markup Language docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What is the default option of a select element when none is selected?
2 participants