CSS

:默认 | :default

:default

:defaultCSSpseudo-class表示一组相关元素中的默认表单元素。

/* Selects default element among a group */ :default { background-color: lime; }

允许多个选择的分组元素也可以具有多个默认值,即,它们可以具有最初选择的多个项目。在这种情况下,所有默认值都使用:default伪类表示。例如,您可以在一组复选框之间设置默认复选框。

语法

:default

示例

:default { background-color: lime; }

...在哪里...

<form method="get"> <p><input type="submit" id="submit1"></p> <p><input type="submit" id="submit2"></p> <p><input type="reset"></p> </form>

这个例子使背景色成为lime窗体中的默认提交按钮。

规范

SpecificationStatusComment
HTML Living StandardThe definition of ':default' in that specification.Living StandardNo change.
HTML5The definition of ':default' in that specification.RecommendationDefines the semantic regarding HTML and constraint validation.
Selectors Level 4The definition of ':default' in that specification.Working DraftNo change.
CSS Basic User Interface Module Level 3The definition of ':default' in that specification.Candidate RecommendationDefines the pseudo-class, but not the associated semantic.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support10.04.0 (2.0)No support10.05.0

FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support?4.0 (2.0)No support10.05.0