Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="container">
  <selectmenu id="my-select">
    <button class="anchor" slot="button" behavior="button">
      <span behavior="selected-value" class="selected-value"></span>
      <svg xmlns="" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true" class="icon">
        <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
    <div popover="" slot="listbox" behavior="listbox">
      <div class="listbox-inner">
        <option value="first option">This is the first option</option>
        <option value="second option">This is the second option</option>
        <option value="third option">This is the third option</option>
        <option value="fourth option">This is the fourth option</option>
        <option value="fifth option">This is the fifth option</option>
        <option value="sixth option">This is the sixth option</option>
  <div id="current-value" class="infobox"></div>


                @import url("");

:root {
  --body-bg: #242038;
  --ui-color: #f7ece1;
  --ui-bg-color: #8d86c9;
  --ui-bg-hover-color: #725ac1;
  --ui-border-radius: 5px;

selectmenu {
  position: relative;
  width: 100%;
  anchor-name: --selectmenu;

selectmenu .anchor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ui-color);
  padding: 12px 18px;
  border-radius: var(--ui-border-radius);
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 2px solid var(--ui-bg-color);
  .icon {
    width: 20px;
    height: 20px;
    transition: transform 0.24s;
  .selected-value {
    min-width: 100px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

selectmenu [popover] {
  box-shadow: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: hidden;
  top: anchor(--selectmenu top);

selectmenu:not(:has(:closed)) {
  box-shadow: rgba(0, 0, 0, 0.1) 0px 20px 25px -5px,
    rgba(0, 0, 0, 0.04) 0px 10px 10px -5px;
  .icon {
    transform: rotate(180deg);
  .anchor {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;

.listbox-inner {
  max-height: 160px;
  overflow-y: auto;
  background: var(--ui-bg-color);
  border-radius: 0 0 var(--ui-border-radius) var(--ui-border-radius);

.listbox-inner option {
  width: auto;
  color: var(--ui-color);
  padding: 10px;
  cursor: pointer;
  transition: background 0.2s;

.listbox-inner option:hover {
  background: var(--ui-bg-hover-color);

.listbox-inner option:last-child {
  border-radius: 0 0 calc(var(--ui-border-radius) - 1px)
    calc(var(--ui-border-radius) - 1px);

.infobox {
  margin-block: 30px;
  padding: 24px;
  color: var(--ui-color);
  border: 1px dashed var(--ui-bg-color);
  border-radius: var(--ui-border-radius);
  font-size: 1.3rem;
  text-align: center;

/**** General styling. *******/
*:before {
  box-sizing: border-box;

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 200vh;
  justify-content: center;
  align-items: center;
  font-family: "Lato", sans-serif;
  background: var(--body-bg);

.container {
  width: 100%;
  max-width: 600px;



                const mySelect = document.getElementById("my-select");
const infoBox = document.getElementById("current-value");

infoBox.innerHTML = `You chose the ${mySelect.value}`;

mySelect.addEventListener('change', (e) => {
  infoBox.innerHTML = `You chose the ${}`;