CSS User Interface
In this page:
appearance: Removing Native Form Styling
Browsers apply their own native OS-level styling to form elements like checkboxes, radio buttons, and select dropdowns. The appearance property, usually set to none, strips this native styling away so you can apply fully custom CSS instead, which is the first step in building any custom-styled form control.
Example: appearance: Removing Native Form Styling
<style>
input[type="checkbox"] {
appearance: none;
width: 16px;
height: 16px;
border: 2px solid gray;
}
</style>
<input type="checkbox">
accent-color: Quick Native Control Coloring
For cases where you do not need full custom control styling, accent-color lets you simply recolor a checkbox, radio button, range slider, or progress bar to match your brand while keeping the browser's native control shape and behavior — a much lighter-weight option than appearance: none.
Example: accent-color: Quick Native Control Coloring
<style>
input {
accent-color: crimson;
}
</style>
<input type="checkbox" checked>
<input type="range">
caret-color: The Text Cursor Blink
caret-color changes the color of the blinking text-insertion cursor inside an input or textarea. This is a small but noticeable detail on dark-themed forms, where the default black caret can be nearly invisible against a dark background.
Example: caret-color: The Text Cursor Blink
<style>
input {
background: #222;
color: white;
caret-color: lime;
}
</style>
<input type="text" value="Dark theme input">
outline-offset: Spacing a Focus Ring
outline-offset adds space between an element's edge and its outline (commonly a focus ring), pushing the ring outward instead of having it sit flush against the border. This is especially useful on rounded elements, where a flush outline would look cramped against the curve.
Example: outline-offset: Spacing a Focus Ring
<style>
button {
border-radius: 50%;
outline: 2px solid blue;
outline-offset: 4px;
}
</style>
<button>Round</button>
user-select: Controlling Text Selection
user-select controls whether text inside an element can be selected/highlighted by the user at all. Setting it to none is common on UI chrome like button labels or drag handles, where accidental text selection during interaction looks broken, while normal content text should always leave it at its default auto value.
Example: user-select: Controlling Text Selection
<style>
.label {
user-select: none;
}
</style>
<button class="label">Drag handle, not selectable</button>
Chapter Quiz — Complete all 25 topics to unlock
0/25 topics done
Complete these topics first:
- CSS Container Queries
- CSS Subgrid
- CSS Logical Properties
- CSS Logical Sizing
- CSS Writing Modes
- CSS Aspect Ratio
- CSS Object Fit
- CSS object-position
- CSS Masking
- CSS Math Functions
- CSS Motion Path
- CSS @supports
- CSS @property
- CSS At-Rules
- CSS Cursor
- CSS Will Change
- CSS User Interface
- CSS Print Styles
- CSS Pagination (Print)
- CSS Dark Mode
- CSS Accessibility
- CSS Performance
- CSS Preprocessors
- CSS Frameworks Overview
- CSS Interview Prep