CSS参考手册
基本用户界面 | Basic User Interface
必须选择器 | :required
:required
CSS伪类 表示 任意 <input>
元素表示任意拥有required
属性的 <input>
或 <textarea>
元素使用它. 它允许表单在提交之前容易的展示必填字段并且渲染其外观.
/* Selects <input> elements, but only if they */
/* have got required set on them */
input:required {
border: 1px dashed red;
}
:optional
伪类可用于表单可选元素提供外观.
语法
:required
示例
查看示例:invalid
.
规范
Specification |
Status |
Comment |
---|---|---|
HTML Living StandardThe definition of ':required' in that specification. |
Living Standard |
No change. |
HTML5The definition of ':required' in that specification. |
Recommendation |
Defines the semantic regarding HTML and constraint validation. |
Selectors Level 4The definition of ':required' in that specification. |
Working Draft |
No change. |
CSS Basic User Interface Module Level 3The definition of ':required' in that specification. |
Candidate Recommendation |
Defines the pseudo-class, but not the associated semantic. |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic support |
10.0 |
(Yes) |
4.0 (2) |
10 |
10.0 |
5.0 |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|
Basic support |
4.4.4 |
(Yes) |
4.0 (2) |
No support |
10.0 |
5.0 |
基本用户界面 | Basic User Interface相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。