liveBook · Manning

Dropdown

As explained in Tiny CSS Projects

A select element is an HTML form control that presents a list of options from which a user can make a selection.

A <select> lets users choose from a list of options. In a contact form, shared CSS can bring it closer to the look of text inputs and textareas, though operating-system styling limits how far the menu can be customized. section 10.0 section 10.4

Useful styling steps include:

  • Add select to existing form-control rules to share typography, color, border, padding, and width. section 10.3.2
  • Set the background to the card color so the control follows the form’s theme. section 10.4
  • Use a pointer cursor on hover to signal that the menu is clickable. section 10.9.2

CSS alone cannot fully restyle the options menu because its appearance and behavior partly come from the operating system. Replacing the native control with JavaScript and ARIA means recreating its accessibility information and functionality as well as its appearance. section 10.4

Listing 10.15 Default styles applied to select
input:not([type="radio"], [type="checkbox"]),
textarea,
select {
  font-size: 1rem;
  font-family: inherit;
  color: inherit;
  border: none;
  border-bottom: solid 1px var(--primary);
  border-image: linear-gradient(to right, var(--primary), var(--accent)) 1;
  padding: 0 0 .25rem;
  margin-bottom: 2rem;
  width: 100%;
  background-color: var(--background-card);     #1
}

See the shared control rule with the card-background color applied to select. section 10.4

How Tiny CSS Projects covers it

How deep it goes
Applies shared control styles, a background color, and a hover cursor, then stops short of fully restyling native options.
Examples
Uses a contact-form select with a card-colored background and a pointer cursor on hover.
What it assumes
Assumes an existing form and shared CSS rules for text inputs, while treating native select behavior as browser- and operating-system-provided.
What you can do after
Apply CSS to align a native select with other form controls and signal its clickability.
How it connects
Connects HTML forms and CSS styling with operating-system controls and accessibility through ARIA.

Also explained in

Compare how 10 books explain dropdown →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.