Form Control Styling Beyond the Basics
Native form controls are the fastest path to accessible forms. Complete the Forms and Token Review reading before this choose topic. It introduces accent-color and field-sizing, which you apply on a contact form in the CV Page, Print Stylesheet, and Contact Form prove assignment.
This choose topic goes beyond that foundation. You will strip and replace native chrome with appearance, work around what <select> and file inputs will not let you style, set caret-color on text fields, unify :focus-visible rings across control types, and push range inputs past what accent-color alone can do. For how custom-styled controls behave under Windows High Contrast Mode, see the Unit 3 choose topic Print and Forced Colors.
appearance and Native-First Styling
Every form control ships with a browser-native appearance built from the operating system's UI toolkit. That appearance is what makes a checkbox look like a checkbox and a range slider look like a slider without any CSS from you. The appearance property lets you opt out of that rendering.
/* Strip all native chrome */
input[type="checkbox"] {
appearance: none;
}
Setting appearance: none gives you a blank canvas. The control loses its native shape, color, and in some cases its interactive affordances. You are now responsible for every pixel, including the checked state, the focus ring, and any animation. That is a significant commitment for checkboxes and radio buttons, which require custom ::before or ::after content to remain visually meaningful.
The native-first approach is usually the better starting point. Use accent-color (covered in Forms and Token Review) to tint native controls your brand color, use :focus-visible to standardize the ring, and only reach for appearance: none on controls where the native chrome genuinely blocks what you need to achieve. A styled-from-scratch checkbox that works in every browser, respects high-contrast mode, and reads correctly to screen readers takes considerably more work than one that inherits its semantics from the OS.
appearance: none
Windows High Contrast mode and the forced-colors media feature rely on native control rendering to apply system colors correctly. Controls with appearance: none that use custom colors will often lose those colors entirely in forced-colors environments, leaving users with invisible or broken controls. If you do strip native appearance, test under @media (forced-colors: active) and restore appropriate system colors. See Print and Forced Colors for the full forced-colors toolkit.
<select> and File Input Limits
<select> is one of the most requested and most frustrating controls to style. The element box itself is styleable: you can set background, padding, border, and font. The dropdown list that appears when the user opens the select is rendered by the operating system and is not styleable from CSS in any browser.
The standard approach is to set appearance: none to remove the native arrow, then add your own using a background SVG image or a mask icon positioned to the right.
select {
appearance: none;
background-color: var(--color-surface);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right var(--spacing-sm) center;
background-size: 1rem;
padding-inline-end: 2.5rem;
}
The arrow SVG is embedded as a data URI. The fill color is hardcoded in the URI, which means it will not adapt to dark mode automatically. One workaround is to use two background declarations inside a prefers-color-scheme block, one with a light-friendly fill and one with a dark-friendly fill. Another is to swap the background image for a mask approach, which lets background-color: currentColor handle theming.
File inputs are similarly constrained. The button portion can be targeted with ::file-selector-button and styled like any button. The filename text area beside it accepts almost no styling. Fully custom file inputs typically hide the native input with opacity: 0 and use a <label> as the visible trigger, though this requires care to maintain keyboard and screen reader accessibility.
caret-color
The text insertion caret in inputs and textareas defaults to the browser's choice, usually the element's color value or a system accent color. caret-color lets you set it independently.
input[type="text"],
input[type="email"],
input[type="url"],
textarea {
caret-color: var(--color-accent);
}
This is a small detail that ties the editing experience to your brand color without touching the text color itself. It pairs naturally with a matching :focus-visible ring so the caret and the ring use the same accent value and feel intentional rather than accidental.
Consistent :focus-visible Rings
Different control types render their focus indicators differently by default. A text input might show a blue outline, a select might show a glow, and a range input might show nothing visible at all in some browsers. Unifying these creates a predictable, accessible experience across your entire form.
The pattern is to reset the default outline on all controls at once, then apply a single consistent ring using :focus-visible. Using :focus-visible instead of :focus ensures the ring only appears for keyboard navigation, not mouse clicks.
input,
select,
textarea {
outline: none;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}
Setting outline: none without the :focus-visible replacement that follows it makes your form completely unusable for keyboard and switch-access users. Always pair the reset with a replacement. If you are unsure whether your replacement meets contrast requirements, check it against WCAG 2.1 Success Criterion 1.4.11.
Range inputs frequently need the :focus-visible rule applied to their thumb pseudo-element as well, since the track itself may receive focus in some browsers while the thumb receives it in others.
input[type="range"]:focus-visible {
outline: none;
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}
input[type="range"]:focus-visible::-moz-range-thumb {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}
Range Track and Thumb Styling
accent-color (from Forms and Token Review) tints the range thumb and the filled portion of the track in supporting browsers. When you need more control over the track height, thumb size, thumb shape, or independent colors for the filled and unfilled portions, you need vendor-prefixed pseudo-elements.
input[type="range"] {
appearance: none;
height: 4px;
background: transparent;
cursor: pointer;
}
/* Track - WebKit */
input[type="range"]::-webkit-slider-runnable-track {
background: var(--color-border-strong);
border-radius: var(--radius-sm);
height: 4px;
}
/* Track - Firefox */
input[type="range"]::-moz-range-track {
background: var(--color-border-strong);
border-radius: var(--radius-sm);
height: 4px;
}
/* Thumb - WebKit */
input[type="range"]::-webkit-slider-thumb {
appearance: none;
background: var(--color-accent);
border: none;
border-radius: 50%;
height: 1rem;
margin-block-start: -6px;
width: 1rem;
}
/* Thumb - Firefox */
input[type="range"]::-moz-range-thumb {
background: var(--color-accent);
border: none;
border-radius: 50%;
height: 1rem;
width: 1rem;
}
The WebKit thumb requires a negative margin-block-start to center it vertically over the track because the thumb does not auto-center relative to the track height when appearance: none is set. Firefox handles centering automatically. Test both and adjust the margin value to match your track height.
There is currently no cross-browser CSS-only way to color only the filled portion of the track independently from the unfilled portion without JavaScript. Chrome and Safari do not expose a ::-webkit-slider-fill or equivalent pseudo-element. Firefox exposes ::-moz-range-progress for the filled side. If you need a filled-track style in all browsers, a small JS snippet that updates a CSS custom property based on the input's current value is the current standard approach.
Build Your Demo
You have two paths for this teaching video demo:
-
Standalone showcase: build at
unit-5/form-controls/with its ownindex.htmland linked stylesheet - Prove integration: apply these techniques on the contact form in the CV Page, Print Stylesheet, and Contact Form prove assignment and satisfy both at once. If you have already submitted the prove, use the standalone path.
Either way, your form should include:
-
At least one text input and one email or URL input with semantic
label,for, andidpairs -
A
<select>with a custom arrow (appearance: noneplus a background SVG or mask icon) -
A range input with styled track and thumb if you need more control than
accent-color - A textarea
-
caret-coloron text fields -
One shared
:focus-visiblering across every control type, including range thumb pseudo-elements in WebKit and Firefox
Start with plain markup so you can compare before and after in your video. Tab through the finished form in Chrome and Firefox. If you strip native appearance anywhere, test under forced-colors: active or note the limitation in your video.
Teaching Video Checklist
When you record your teaching video, make sure your teammates come away understanding these concepts:
-
The tradeoff between
appearance: noneand native-first styling, and why stripping native chrome has real accessibility costs -
What parts of a
<select>can and cannot be styled, and the custom arrow technique using a background SVG -
How
caret-colorties the text cursor to a brand token without changing the text color -
Why different control types have inconsistent default focus rings and how a single
:focus-visibleruleset unifies them -
When
accent-coloris enough for range inputs and when vendor-prefixed track and thumb pseudo-elements are worth the extra maintenance -
Your portfolio demo: a form with text inputs, a custom-styled select, and a range input that share one
:focus-visibletreatment
Start with the inconsistent default focus rings on an unstyled form, then show how your unified :focus-visible ruleset makes keyboard navigation predictable across control types.
Resources
- MDN: appearance - Property values, browser support, and accessibility considerations
-
MDN: caret-color - Syntax and interaction with the
autovalue - MDN: :focus-visible - How the browser decides when to show the ring and how to override it safely
- MDN: ::file-selector-button - Styling the button portion of file inputs
-
Can I Use: appearance - Current browser support including the
nonevalue - Can I Use: caret-color - Browser support data