Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:default — default form elements

The :default pseudo-class selects default interface elements, not necessarily the currently selected ones. It can highlight the default choice even after the user changes their selection.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

:default { /* declarations */ }
input:default + label { /* declarations */ }

:default is a pseudo-class without arguments that selects default elements among related interface elements. Multiple elements can match at once. In HTML, it covers a form’s default submit button, checkbox or radio input elements with the checked attribute, and option elements with the selected attribute. It does not select the select itself.

Do not confuse it with :checked, which reflects the current selection. User selection changes do not remove the checked or selected attribute, so the default element still matches :default. However, this is not an immutable snapshot of the initial state: changing those attributes through script can change matching.

In the example, input:default + label underlines the default input’s label, while input:checked + label makes the current choice’s label bold. After selecting B, A remains underlined. Styling alone neither sets a default value nor changes form behavior.

Examples

<!doctype html>
<meta charset="utf-8">
<title>:default</title>
<style>
  input:default + label { text-decoration: underline; }
  input:checked + label { font-weight: bold; }
</style>
<form autocomplete="off">
  <input id="a" type="radio" name="plan" checked>
  <label for="a">A</label>
  <input id="b" type="radio" name="plan">
  <label for="b">B</label>
  <button type="reset">Reset</button>
</form>

Result

Initial: A is underlined and bold; B is neither.
After selecting B: A remains underlined; B is bold.
After Reset: A is underlined and bold; B is neither.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources