首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

:默认 | :default

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

代码语言:javascript
复制
/* Selects default element among a group */
:default {
  background-color: lime;
}

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

语法

代码语言:javascript
复制
:default

示例

代码语言:javascript
复制
:default
{
  background-color: lime;
}

...在哪里...

代码语言:javascript
复制
 <form method="get">
  <p><input type="submit" id="submit1"></p>
  <p><input type="submit" id="submit2"></p>
  <p><input type="reset"></p>
 </form>

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

规范

Specification

Status

Comment

HTML Living StandardThe definition of ':default' in that specification.

Living Standard

No change.

HTML5The definition of ':default' in that specification.

Recommendation

Defines the semantic regarding HTML and constraint validation.

Selectors Level 4The definition of ':default' in that specification.

Working Draft

No change.

CSS Basic User Interface Module Level 3The definition of ':default' in that specification.

Candidate Recommendation

Defines the pseudo-class, but not the associated semantic.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

10.0

4.0 (2.0)

No support

10.0

5.0

Feature

Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

?

4.0 (2.0)

No support

10.0

5.0

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com