<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r" -->

---
title: The customizable select - Part five: Optgroup, creating...
description: Part five of a series on the customizable HTML select element focuses on styling the <optgroup> element using the emerging appearance: base-select CSS feature....
canonical: https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The customizable select - Part five: Optgroup, creating a true select menu | daily.dev
og:description: Part five of a series on the customizable HTML select element focuses on styling the <optgroup> element using the emerging appearance: base-select CSS feature....
og:url: https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r
og:image: https://api.daily.dev/og/posts/pgnBBmU2R.png
og:image:alt: The customizable select - Part five: Optgroup, creating a true select menu
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The customizable select - Part five: Optgroup, creating a true select menu

**[utilitybend](https://daily.dev/sources/utilitybend)** · 8 min read · 0 upvotes · 0 comments

## Summary

Part five of a series on the customizable HTML select element focuses on styling the <optgroup> element using the emerging appearance: base-select CSS feature. A restaurant-style dish picker demo shows how to build a select with a label, selectedcontent element, a disabled placeholder option, and optgroups styled as category headers. Techniques covered include using ::picker(select) with position-anchor to create a full-screen picker, CSS columns for multi-column option layout, break-inside/break-before to keep optgroups grouped with their first option, and a hover-reveal trick using ::after with attr() to show optgroup labels only on hover. The piece ends with an idea for a country selector organized by continent optgroups.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://utilitybend.com/blog/the-customizable-select-part-five-optgroup-creating-a-true-select-menu>

## Questions this post answers

### How do you style the optgroup element inside a customizable select with CSS?

Optgroup elements can be styled directly once appearance: base-select is opted into on the select. You can set padding, margins, borders, fonts, and text alignment on the optgroup selector just like any other element, letting category labels look like headings inside a picker rather than plain browser-default text.

_Developers building custom select menus can track new CSS select styling techniques like this on daily.dev._

### How do you keep an optgroup's label attached to its first option when using CSS columns inside a select picker?

Apply break-inside: avoid to the option element and break-before: avoid to the first option in each group. This prevents CSS multi-column layout from splitting an optgroup heading away from its first option, keeping each category visually intact across column breaks.

_Anyone laying out multi-column dropdowns can find CSS layout fixes like this on daily.dev._

### How can you make an optgroup label appear only when its options are hovered using CSS?

Use a ::after pseudo-element on the optgroup with content: attr(value) and opacity: 0 by default, then set opacity: 1 when the optgroup is hovered, or when it has an option that is hovered or focus-visible. This hides the category label until the user interacts with that group's options.

_Developers experimenting with hover-based CSS reveals can follow more select styling tricks on daily.dev._

## Similar posts on daily.dev

- [Abusing Customizable Selects](https://daily.dev/posts/abusing-customizable-selects-hyfhou2vz) · CSS-Tricks · 14 upvotes · 1 comments
- [Nice Select · February 3, 2026](https://daily.dev/posts/nice-select-february-3-2026-d8jdnzuo9) · Adam Argyle · 3 upvotes · 0 comments
- [The <selectmenu> Element: Stop Using JavaScript Dropdown Libraries](https://daily.dev/posts/the-selectmenu-element-stop-using-javascript-dropdown-libraries-22c9sm7x7) · SitePoint · 22 upvotes · 0 comments
- [The golden rule of Customizable Select](https://daily.dev/posts/the-golden-rule-of-customizable-select-ovcvnr5yr) · WebKit · 3 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The customizable select - Part five: Optgroup, creating a true select menu","url":"https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r"},"datePublished":"2026-09-20T07:43:29.880Z","dateModified":"2026-09-20T07:44:39.031Z","description":"Part five of a series on the customizable HTML select element focuses on styling the \u003coptgroup\u003e element using the emerging appearance: base-select CSS feature....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/265401f3a6bebcbdb165b30aca81bd07?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/265401f3a6bebcbdb165b30aca81bd07?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"utilitybend","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"utilitybend","logo":"https://media.daily.dev/image/upload/s--hONVFSz4--/f_auto,q_auto/v1789890196/logos/utilitybend?_a=BAMAMicg0","url":"https://daily.dev/sources/utilitybend"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css,html,accessibility","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"utilitybend","item":"https://daily.dev/sources/utilitybend"},{"@type":"ListItem","position":3,"name":"The customizable select - Part five: Optgroup, creating a true select menu"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-customizable-select---part-five-optgroup-creating-a-true-select-menu-pgnbbmu2r#faq","mainEntity":[{"@type":"Question","name":"How do you style the optgroup element inside a customizable select with CSS?","acceptedAnswer":{"@type":"Answer","text":"Optgroup elements can be styled directly once appearance: base-select is opted into on the select. You can set padding, margins, borders, fonts, and text alignment on the optgroup selector just like any other element, letting category labels look like headings inside a picker rather than plain browser-default text. Developers building custom select menus can track new CSS select styling techniques like this on daily.dev."}},{"@type":"Question","name":"How do you keep an optgroup's label attached to its first option when using CSS columns inside a select picker?","acceptedAnswer":{"@type":"Answer","text":"Apply break-inside: avoid to the option element and break-before: avoid to the first option in each group. This prevents CSS multi-column layout from splitting an optgroup heading away from its first option, keeping each category visually intact across column breaks. Anyone laying out multi-column dropdowns can find CSS layout fixes like this on daily.dev."}},{"@type":"Question","name":"How can you make an optgroup label appear only when its options are hovered using CSS?","acceptedAnswer":{"@type":"Answer","text":"Use a ::after pseudo-element on the optgroup with content: attr(value) and opacity: 0 by default, then set opacity: 1 when the optgroup is hovered, or when it has an option that is hovered or focus-visible. This hides the category label until the user interacts with that group's options. Developers experimenting with hover-based CSS reveals can follow more select styling tricks on daily.dev."}}]}
```

