:default

Baseline 广泛可用

此功能非常成熟,可以在许多设备和浏览器版本上运行。它从 2020年1月.

报告反馈

试试看

The :default CSS pseudo-class selects form elements that are the default in a group of related elements.

语法

<button> matches if it is a <form>'s default submission button: the first <button> in DOM order that belongs to the form. This also applies to <input> types that submit forms, like image or submit.
:default {
  /* ... */
}

示例

HTML

css
<fieldset>
  <legend>Favorite season</legend>

  <input type="radio" name="season" id="spring" value="spring" />
  <label for="spring">Spring</label>

  <input type="radio" name="season" id="summer" value="summer" checked />
  <label for="summer">Summer</label>

  <input type="radio" name="season" id="fall" value="fall" />
  <label for="fall">Fall</label>

  <input type="radio" name="season" id="winter" value="winter" />
  <label for="winter">Winter</label>
</fieldset>

CSS

<button> matches if it is a <form>'s default submission button: the first <button> in DOM order that belongs to the form. This also applies to <input> types that submit forms, like image or submit.
input:default {
  box-shadow: 0 0 2px 1px coral;
}

input:default + label {
  color: coral;
}

html

规范

结果
规范
# HTML 标准
selector-default
# 选择器级别 4

浏览器兼容性

default-pseudo

另请参见