Skip to content

Commit 34d4f10

Browse files
chrisdavidmillsbramus
authored andcommitted
Editorial review: Document customizable <select> elements (mdn#38470)
* Document customizable <select> elements * fix typo * Finish guide * correct info about how <selectedcontent> is populated * add links to customizable select guide, update existing pages, remove unneeded links * Document selectedcontent element * Add doc for ::picker() * Document appearance: base-select, tweak :open and :checked ref pages * Document the ::picker-icon and ::checkmark pseudos * Add notes on implicit popover-invoker relationship and anchor reference * Add default picker styling info, tweak other info * Fixes for josepharhar review comments * Fixes for josepharhar review comments * Fixes for scottaohara review comments * Accessibility and <select> content fixes * Additional fixes * Additional fixes * Additional fixes * Fixes for hamishwillee review comments * Change other elements back to other content * Last few tweaks from hamishwillee review
1 parent 77e2e0c commit 34d4f10

File tree

32 files changed

+985
-145
lines changed

32 files changed

+985
-145
lines changed

files/en-us/learn_web_development/extensions/forms/advanced_form_styling/index.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: Learn_web_development/Extensions/Forms/Advanced_form_styling
44
page-type: learn-module-chapter
55
---
66

7-
{{LearnSidebar}}{{PreviousMenuNext("Learn_web_development/Extensions/Forms/Styling_web_forms", "Learn_web_development/Extensions/Forms/UI_pseudo-classes", "Learn_web_development/Extensions/Forms")}}
7+
{{LearnSidebar}}{{PreviousMenuNext("Learn_web_development/Extensions/Forms/Styling_web_forms", "Learn_web_development/Extensions/Forms/Customizable_select", "Learn_web_development/Extensions/Forms")}}
88

99
In this article, we will see what can be done with CSS to style the types of form control that are more difficult to style — the "bad" and "ugly" categories. As we saw [in the previous article](/en-US/docs/Learn_web_development/Extensions/Forms/Styling_web_forms), text fields and buttons are perfectly easy to style; now we will dig into styling the more problematic bits.
1010

@@ -38,6 +38,8 @@ To recap what we said in the previous article, we have:
3838
**The ugly**: Some elements can't be styled thoroughly using CSS. These include:
3939

4040
- Elements involved in creating dropdown widgets, including {{HTMLElement("select")}}, {{HTMLElement("option")}}, {{HTMLElement("optgroup")}} and {{HTMLElement("datalist")}}.
41+
> [!NOTE]
42+
> Some browsers now support [Customizable select elements](/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select), a set of HTML and CSS features that together enable full customization of `<select>` elements and their contents just like any regular DOM elements.
4143
- [`<input type="color">`](/en-US/docs/Web/HTML/Element/input/color)
4244
- Date-related controls such as [`<input type="datetime-local">`](/en-US/docs/Web/HTML/Element/input/datetime-local)
4345
- [`<input type="range">`](/en-US/docs/Web/HTML/Element/input/range)
@@ -367,9 +369,9 @@ Let's talk about some specifics of each of these types of control, highlighting
367369

368370
### Selects and datalists
369371

370-
In modern browsers, selects and datalists are generally not too bad to style provided you don't want to vary the look and feel too much from the defaults.
372+
Some browsers now support [Customizable select elements](/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select), a set of HTML and CSS features that together enable full customization of `<select>` elements and their contents just like any regular DOM elements. In supporting browsers and codebases, you no longer need to worry about the legacy techniques described below for `<select>` elements.
371373

372-
We've managed to get the basic look of the boxes looking pretty uniform and consistent. The datalist control is `<input type="text">` anyway, so we knew this wouldn't be a problem.
374+
Styling datalists and selects (in browsers that don't support customizable selects) allows an acceptable level of customization provided you don't want to vary the look and feel too much from the defaults. We've managed to get the basic look of the boxes looking pretty uniform and consistent. The datalist invoking control is an `<input type="text">` anyway, so we knew this wouldn't be a problem.
373375

374376
Two things are slightly more problematic. First of all, the select's "arrow" icon that indicates it is a dropdown differs across browsers. It also tends to change if you increase the size of the select box, or resize in an ugly fashion. To fix this in our example we first used our old friend `appearance: none` to get rid of the icon altogether:
375377

@@ -508,17 +510,10 @@ You can see the result of the above CSS styling in the below live example (see a
508510

509511
It is easier to just create your own custom solution for these features, if you want to be able to control the styling, or use a third-party solution such as [progressbar.js](https://kimmobrunfeldt.github.io/progressbar.js/#examples).
510512

511-
The article [How to build custom form controls](/en-US/docs/Learn_web_development/Extensions/Forms/How_to_build_custom_form_controls) provides an example of how to build a custom designed select with HTML, CSS, and JavaScript.
512-
513513
## Summary
514514

515515
While there are still difficulties using CSS with HTML forms, there are ways to get around many of the problems. There are no clean, universal solutions, but modern browsers offer new possibilities. For now, the best solution is to learn more about the way the different browsers support CSS when applied to HTML form controls.
516516

517-
In the next article of this module, we will explore the different [UI pseudo-classes](/en-US/docs/Learn_web_development/Extensions/Forms/UI_pseudo-classes) available to us in modern browsers for styling forms in different states.
518-
519-
{{PreviousMenuNext("Learn_web_development/Extensions/Forms/Styling_web_forms", "Learn_web_development/Extensions/Forms/UI_pseudo-classes", "Learn_web_development/Extensions/Forms")}}
520-
521-
### Advanced Topics
517+
In the next article of this module, we will explore creating [fully-customized `<select>` elements](/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select) using the dedicated, modern HTML and CSS features available for this purpose.
522518

523-
- [How to build custom form controls](/en-US/docs/Learn_web_development/Extensions/Forms/How_to_build_custom_form_controls)
524-
- [Sending forms through JavaScript](/en-US/docs/Learn_web_development/Extensions/Forms/Sending_forms_through_JavaScript)
519+
{{PreviousMenuNext("Learn_web_development/Extensions/Forms/Styling_web_forms", "Learn_web_development/Extensions/Forms/Customizable_select", "Learn_web_development/Extensions/Forms")}}

files/en-us/learn_web_development/extensions/forms/basic_native_form_controls/index.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,3 @@ You've reached the end of this article, but can you remember the most important
415415
This article has covered the older input types — the original set introduced in the early days of HTML that is well-supported in all browsers. In the next section, we'll take a look at the more modern values of the `type` attribute.
416416

417417
{{PreviousMenuNext("Learn_web_development/Extensions/Forms/How_to_structure_a_web_form", "Learn_web_development/Extensions/Forms/HTML5_input_types", "Learn_web_development/Extensions/Forms")}}
418-
419-
### Advanced Topics
420-
421-
- [How to build custom form controls](/en-US/docs/Learn_web_development/Extensions/Forms/How_to_build_custom_form_controls)
422-
- [Sending forms through JavaScript](/en-US/docs/Learn_web_development/Extensions/Forms/Sending_forms_through_JavaScript)

0 commit comments

Comments
 (0)