MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

摘要

:optional CSS 伪类 表示任意没有required属性的 <input> 或 <textarea> 元素使用它. 它允许表单容易的展示可选字段并且渲染其外观.

为必填字段设置外观,请使用 :required伪类.

语法

:optional { style properties }

例子

查看示例:invalid .

规范

Specification Status Comment
WHATWG HTML Living Standard
:optional
Living Standard No change.
HTML5
:optional
Recommendation Defines the semantic regarding HTML and constraint validation.
Selectors Level 4
:optional
Working Draft No change.
CSS Basic User Interface Module Level 3
:optional
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) 10 10.0 5.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 4.0 (2) 未实现 10.0 5.0

参见

文档标签和贡献者

 此页面的贡献者: liyongleihf2006
 最后编辑者: liyongleihf2006,