# Floating Label Select

> A native select with a label that sits inside like a placeholder, then floats up once an option is chosen.

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: select, floating label, dropdown, placeholder, invalid, form
- Live preview: https://copy-css.com/snippets/floating-label-select
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<label class="float-select">
  <select name="country" required>
    <option value="" disabled selected></option>
    <option>Canada</option>
    <option>Germany</option>
    <option>Japan</option>
  </select>
  <span>Country</span>
</label>
```

## CSS

```css
.float-select {
  position: relative;
  display: block;
  width: 240px;
  font-family: system-ui, sans-serif;
}

.float-select select {
  box-sizing: border-box;
  width: 100%;
  height: 54px;
  padding: 20px 40px 4px 14px;
  border: 1.5px solid #a7f3d0;
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23047857' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 16px;
  color: #064e3b;
  font: 16px system-ui, sans-serif;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.float-select span {
  position: absolute;
  top: 10px;
  left: 15px;
  color: #059669;
  font-size: 12px;
  pointer-events: none;
  transition: top 0.2s ease, font-size 0.2s ease;
}

.float-select select:invalid + span {
  top: 17px;
  color: #6b7280;
  font-size: 16px;
}

.float-select select:focus-visible {
  border-color: #059669;
  outline: none;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .float-select span {
    transition: none;
  }
}
```

## Notes

- This CSS Floating Label Select is 49 lines of pure CSS (1.2 KB) with no JavaScript and no dependencies. It uses transitions, box shadows, keyboard focus styles and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
