The following compatibility tables try to summarize the state of CSS support for HTML forms. Due to the complexity of CSS and HTML forms, these tables can't be considered a perfect reference. However, they will give you good insight into what can and can't be done, which will help you learn how to do things.
For each property, there are four possible values:
There's reasonably consistent support for the property across browsers. You may still face strange side effects in certain edge cases.
While the property works, you may frequently face strange side effects or inconsistencies. You should probably avoid these properties unless you master those side effects first.
The property doesn't work or is so inconsistent that it's not reliable.
The property has no meaning for this type of widget.
For each property there are two possible renderings:
Indicates that the property is applied as it is
Indicates that the property is applied with the extra rule below:
* {
/* Turn off the native look and feel */
-webkit-appearance: none;
appearance: none;
/* for Internet Explorer */
background: none;
}
Some behaviors are common to many browsers at a global level:
border
,
background
,
border-radius
,
height
Using one of these properties can partially or fully turn off the native look & feel of widgets on some browsers. Be careful when you use them.
line-height
This property is supported inconsistently across browsers and you should avoid it.
text-decoration
This property is not supported by Opera on form widgets.
text-overflow
Opera, Safari, and IE9 do not support this property on form widgets.
text-shadow
Opera does not support
text-shadow
on form widgets and IE9 does not support it at all.
见
text
,
search
,和
password
input types.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Partial [1][2] | Yes |
|
border
|
Partial [1][2] | Yes |
|
margin
|
Yes | Yes | |
padding
|
Partial [1][2] | Yes |
|
| Text and font | |||
color
[1]
|
Yes | Yes |
|
font
|
Yes | Yes |
See the note about
line-height
|
letter-spacing
|
Yes | Yes | |
text-align
|
Yes | Yes | |
text-decoration
|
Partial | Partial | See the note about Opera |
text-indent
|
Partial [1] | Partial [1] |
|
text-overflow
|
Partial | Partial | |
text-shadow
|
Partial | Partial | |
text-transform
|
Yes | Yes | |
| Border and background | |||
background
|
Partial [1] | Yes |
|
border-radius
|
Partial [1][2] | Yes |
|
box-shadow
|
No | Partial [1] |
|
见
button
,
submit
,和
reset
input types and the
元素。
<button>
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Partial [1] | Yes |
|
border
|
Partial | Yes | |
margin
|
Yes | Yes | |
padding
|
Partial [1] | Yes |
|
| Text and font | |||
color
|
Yes | Yes | |
font
|
Yes | Yes |
See the note about
line-height
.
|
letter-spacing
|
Yes | Yes | |
text-align
|
No | No | |
text-decoration
|
Partial | Yes | |
text-indent
|
Yes | Yes | |
text-overflow
|
No | No | |
text-shadow
|
Partial | Partial | |
text-transform
|
Yes | Yes | |
| Border and background | |||
background
|
Yes | Yes | |
border-radius
|
Yes [1] | Yes [1] |
|
box-shadow
|
No | Partial [1] |
|
See the
number
input type. There is no standard way to change the style of spinners used to change the value of the field, with the spinners on Safari being outside the field.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Partial [1] | Partial [1] |
|
border
|
Yes | Yes | |
margin
|
Yes | Yes | |
padding
|
Partial [1] | Partial [1] |
|
| Text and font | |||
color
|
Yes | Yes | |
font
|
Yes | Yes |
See the note about
line-height
.
|
letter-spacing
|
Yes | Yes | |
text-align
|
Yes | Yes | |
text-decoration
|
Partial | Partial | |
text-indent
|
Yes | Yes | |
text-overflow
|
No | No | |
text-shadow
|
Partial | Partial | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
No | No |
Supported but there is too much inconsistency between browsers to be reliable. |
border-radius
|
No | No | |
box-shadow
|
No | No | |
见
checkbox
and
radio
input types.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
No [1] | No [1] |
|
height
|
No [1] | No [1] |
|
border
|
No | No | |
margin
|
Yes | Yes | |
padding
|
No | No | |
| Text and font | |||
color
|
N.A. | N.A. | |
font
|
N.A. | N.A. | |
letter-spacing
|
N.A. | N.A. | |
text-align
|
N.A. | N.A. | |
text-decoration
|
N.A. | N.A. | |
text-indent
|
N.A. | N.A. | |
text-overflow
|
N.A. | N.A. | |
text-shadow
|
N.A. | N.A. | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
No | No | |
border-radius
|
No | No | |
box-shadow
|
No | No | |
见
,
<select>
and
<optgroup>
元素。
<option>
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Partial [1] | Partial [1] |
|
height
|
No | Yes | |
border
|
Partial | Yes | |
margin
|
Yes | Yes | |
padding
|
No [1] | Partial [2] |
|
| Text and font | |||
color
|
Partial [1] | Partial [1] |
|
font
|
Partial [1] | Partial [1] |
|
letter-spacing
|
Partial [1] | Partial [1] |
|
text-align
|
No [1] | No [1] |
|
text-decoration
|
Partial [1] | Partial [1] |
|
text-indent
|
Partial [1][2] | Partial [1][2] |
|
text-overflow
|
No | No | |
text-shadow
|
Partial [1][2] | Partial [1][2] |
|
text-transform
|
Partial [1] | Partial [1] |
|
| Border and background | |||
background
|
Partial [1] | Partial [1] |
|
border-radius
|
Partial [1] | Partial [1] | |
box-shadow
|
No | Partial [1] | |
Note Firefox does not provide any way to change the down arrow on the
元素。
<select>
见
,
<select>
and
<optgroup>
elements and the
<option>
size
属性
.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Yes | Yes | |
border
|
Yes | Yes | |
margin
|
Yes | Yes | |
padding
|
Partial [1] | Partial [1] |
|
| Text and font | |||
color
|
Yes | Yes | |
font
|
Yes | Yes |
See the note about
line-height
.
|
letter-spacing
|
Partial [1] | Partial [1] |
|
text-align
|
No [1] | No [1] |
|
text-decoration
|
No [1] | No [1] |
|
text-indent
|
No | No | |
text-overflow
|
No | No | |
text-shadow
|
No | No | |
text-transform
|
Partial [1] | Partial [1] |
|
| Border and background | |||
background
|
Yes | Yes | |
border-radius
|
Yes [1] | Yes [1] |
|
box-shadow
|
No | Partial [1] |
|
见
and
<datalist>
elements and the
<input>
list
属性
.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
No | No | |
height
|
No | No | |
border
|
No | No | |
margin
|
No | No | |
padding
|
No | No | |
| Text and font | |||
color
|
No | No | |
font
|
No | No | |
letter-spacing
|
No | No | |
text-align
|
No | No | |
text-decoration
|
No | No | |
text-indent
|
No | No | |
text-overflow
|
No | No | |
text-shadow
|
No | No | |
text-transform
|
No | No | |
| Border and background | |||
background
|
No | No | |
border-radius
|
No | No | |
box-shadow
|
No | No | |
见
file
input type.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
No | No | |
height
|
No | No | |
border
|
No | No | |
margin
|
Yes | Yes | |
padding
|
No | No | |
| Text and font | |||
color
|
Yes | Yes | |
font
|
No [1] | No [1] |
|
letter-spacing
|
Partial [1] | Partial [1] |
|
text-align
|
No | No | |
text-decoration
|
No | No | |
text-indent
|
Partial [1] | Partial [1] |
|
text-overflow
|
No | No | |
text-shadow
|
No | No | |
text-transform
|
No | No | |
| Border and background | |||
background
|
No [1] | No [1] |
|
border-radius
|
No | No | |
box-shadow
|
No | Partial [1] |
|
见
date
and
time
input types. Many properties are supported, but there is too much inconsistency between browsers to be reliable.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
No | No | |
height
|
No | No | |
border
|
No | No | |
margin
|
Yes | Yes | |
padding
|
No | No | |
| Text and font | |||
color
|
No | No | |
font
|
No | No | |
letter-spacing
|
No | No | |
text-align
|
No | No | |
text-decoration
|
No | No | |
text-indent
|
No | No | |
text-overflow
|
No | No | |
text-shadow
|
No | No | |
text-transform
|
No | No | |
| Border and background | |||
background
|
No | No | |
border-radius
|
No | No | |
box-shadow
|
No | No | |
见
color
input type:
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
No [1] | Yes |
|
border
|
Yes | Yes | |
margin
|
Yes | Yes | |
padding
|
No [1] | Yes |
|
| Text and font | |||
color
|
N.A. | N.A. | |
font
|
N.A. | N.A. | |
letter-spacing
|
N.A. | N.A. | |
text-align
|
N.A. | N.A. | |
text-decoration
|
N.A. | N.A. | |
text-indent
|
N.A. | N.A. | |
text-overflow
|
N.A. | N.A. | |
text-shadow
|
N.A. | N.A. | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
No [1] | No [1] |
|
border-radius
|
No [1] | No [1] | |
box-shadow
|
No [1] | No [1] | |
见
and
<meter>
元素:
<progress>
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Yes | Yes | |
border
|
Partial | Yes | |
margin
|
Yes | Yes | |
padding
|
Yes | Partial [1] |
|
| Text and font | |||
color
|
N.A. | N.A. | |
font
|
N.A. | N.A. | |
letter-spacing
|
N.A. | N.A. | |
text-align
|
N.A. | N.A. | |
text-decoration
|
N.A. | N.A. | |
text-indent
|
N.A. | N.A. | |
text-overflow
|
N.A. | N.A. | |
text-shadow
|
N.A. | N.A. | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
No [1] | No [1] |
|
border-radius
|
No [1] | No [1] | |
box-shadow
|
No [1] | No [1] | |
见
range
input type. There is no standard way to change the style of the range grip and Opera has no way to tweak the default rendering of the range widget.
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Partial [1] | Partial [1] |
|
border
|
No | Yes | |
margin
|
Yes | Yes | |
padding
|
Partial [1] | Yes |
|
| Text and font | |||
color
|
N.A. | N.A. | |
font
|
N.A. | N.A. | |
letter-spacing
|
N.A. | N.A. | |
text-align
|
N.A. | N.A. | |
text-decoration
|
N.A. | N.A. | |
text-indent
|
N.A. | N.A. | |
text-overflow
|
N.A. | N.A. | |
text-shadow
|
N.A. | N.A. | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
No [1] | No [1] |
|
border-radius
|
No [1] | No [1] | |
box-shadow
|
No [1] | No [1] | |
见
image
input type:
| 特性 | N | T | 注意 |
|---|---|---|---|
| CSS box model | |||
width
|
Yes | Yes | |
height
|
Yes | Yes | |
border
|
Yes | Yes | |
margin
|
Yes | Yes | |
padding
|
Yes | Yes | |
| Text and font | |||
color
|
N.A. | N.A. | |
font
|
N.A. | N.A. | |
letter-spacing
|
N.A. | N.A. | |
text-align
|
N.A. | N.A. | |
text-decoration
|
N.A. | N.A. | |
text-indent
|
N.A. | N.A. | |
text-overflow
|
N.A. | N.A. | |
text-shadow
|
N.A. | N.A. | |
text-transform
|
N.A. | N.A. | |
| Border and background | |||
background
|
Yes | Yes | |
border-radius
|
Partial [1] | Partial [1] |
|
box-shadow
|
Partial [1] | Partial [1] |
|
最后修改: , 由 MDN 贡献者