Connect with us

Styling , styling its contents – the box that contains the list of options, and the options themselves – remains very limited.

These limitations often push web developers to use libraries that provide custom select-like controls. Unfortunately using a library comes with important implications: including it in your project increases complexity, your customers will need to download the library code on each visit, and the custom select might not support keyboard navigation or the same accessibility semantics that built-in elements and what limitations still exist, and we’ll introduce a new and experimental element which should, over time, overcome these limitations once and for all.

But before we dive in, let’s review the three main parts of a and contains the currently selected value and a disclosure icon.

  • Listbox: this part appears when the button is selected and serves as a container for the options.
  • Options: these parts are displayed in the listbox and represent the choices users can make.
  • I’ve left out the optgroup part from this list and diagram for simplicity reasons. Let’s not worry about it in this article. Also, the part names I’m using here are not meant to match the actual accessibility semantics of the element and change its background color, borders, font, size, margin, padding, and more.

    With this, we can pretty quickly go from the default style of the across all the main browsers that existed at this time. Now, with Internet Explorer’s retirement around the corner, it’s even easier to get with CSS.

    As a result, we can’t change the default shadow, border, corners, background color, or padding of this box to match the rest of our website.

    It’s important to realize that this part does play an important role in how a element are inherited too.

    For example, it’s possible to change the color and font of the

    Unfortunately, only a small subset of CSS applies to options. Today, in Microsoft Edge (and any other Chromium-based browser), only the following CSS properties are taken into account:

    • background-color
    • color
    • direction
    • font
    • font-family
    • font-size
    • font-style
    • font-variant
    • font-weight
    • text-align
    • text-transform
    • visibility

    This is a good list, and it should be sufficient in most cases. But many interesting effects will not be possible to achieve. As an example, adding horizontal borders between options isn’t possible, and so is adding padding in options to give them more room to breathe. One of the most requested feature is the ability to add images next to options, and this is sadly not possible either since the background-image property doesn’t work. One other example of an interesting effect is using a grid or a flex layout to display the options in a different way. Sadly this is also not possible.

    Enter the element

    There’s good news! Some time ago, a cross-company group of people got together ago and formed Open UI. Their goal is to create specifications for much more extensible and stylable UI controls on the Web. And then work with standard bodies and browser vendors to get them implemented. This is a part of the Web that has, historically, been left out of standardization, and up to browser implementations to deal with on their own. So it’s a very exciting project that aims to fill one of the major remaining gaps on the Web platform today. Also, the people at Open UI are great, and you can join them to follow along or even push some of the proposals!

    Part of the work the group has done so far is already starting to come to fruition. The Microsoft Edge team has started to implement a new HTML element in Chromium, in collaboration with Google, based on the Open UI , and accepting its default design, is a great option!

    But, even if you agree with the above, and I hope you do, I believe a new element like is still necessary. Here’s why: people, still today, build or use custom select elements purely based on aesthetics. Design decisions, not accessibility ones, still lead many web development businesses to roll out their own custom selects. As long as they do, less accessible experiences will continue to exist, complex code will need to be maintained, and heavier bundles will need to be downloaded by users.

    If you were about to start creating your own custom select, I suggest you read Sarah Higley’s excellent 2 part blog post, “Select your poison”, about it first.

    So having a fully stylable select element on the web is an important step in the right direction. It will allow web developers to define the extra styles they need and provide a coherent design, while preserving accessibility and simplicity.

    There’s a progressive enhancement story to this as well. The new element will likely not be available everywhere for a long time and might not ever be as stylable on mobile than on desktop. That’s ok, your website could detect its availability (perhaps using User-Agent Client Hints or checking HTMLSelectMenuElement in JavaScript at runtime), and only use it when possible, letting the browser and OS decide whether to apply your CSS styles. If all you use the element for is styling its various parts like in the example before, then it works just like the can’t achieve today, but that people have wanted for a while, like a combobox.

    Doing this, however, means that the browser might no longer be able to guaranty the accessibility of the control like it can today with a normal and element as easily.

    Closing notes

    As we’ve seen, styling selects on the web isn’t as bad as it used to be in the past. Using the HTML

    Business

    Unlock the Microsoft Copilot Studio-powered customer survey

    With the Copilot-powered customer feedback survey in Dynamics 365 Contact Center, contact center managers can use the generative AI capabilities of Copilot Studio bots to streamline the survey configuration process across channels. Source

    Published

    on

    By

    With the Copilot-powered customer feedback survey in Dynamics 365 Contact Center, contact center managers can use the generative AI capabilities of Copilot Studio bots to streamline the survey configuration process across channels.

    Source

    Continue Reading

    Microsoft

    Announcing Windows 11 Insider Preview Build 22635.4950 (Beta Channel)

    Hello Windows Insiders, today we are releasing Windows 11 Insider Preview Build 22635.4950 (KB5052078) to the Beta Channel. Please note this build will only be provided to Windows Insiders in the Beta Channel  Source

    Published

    on

    By

    Hello Windows Insiders, today we are releasing Windows 11 Insider Preview Build 22635.4950 (KB5052078) to the Beta Channel. Please note this build will only be provided to Windows Insiders in the Beta Channel 

    Source

    Continue Reading

    Business

    A new level unlocked – The Official Microsoft Blog

    Today Microsoft released Muse, a first-of-its-kind generative AI model that we are applying to gaming. But it’s so much more than that. What we’re sharing today is a huge step forward for gameplay ideation. And what’s even more exciting is what this breakthrough represents in our journey of building and using generative AI, and what industries,……

    Published

    on

    By

    Today Microsoft released Muse, a first-of-its-kind generative AI model that we are applying to gaming. But it’s so much more than that. What we’re sharing today is a huge step forward for gameplay ideation. And what’s even more exciting is what this breakthrough represents in our journey of building and using generative AI, and what industries,…

    Source

    Continue Reading

    Trending